core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLSelect.java
private boolean optimizeSort(OClass iSchemaClass) {
    OIndexCursor cursor = getOptimizedSortCursor(iSchemaClass);
    if (cursor != null) {
      fetchValuesFromIndexCursor(cursor);
      return true;
    }
    return false;
  }
private boolean optimizeSort(OClass iSchemaClass) {
    OIndexCursor cursor = getOptimizedSortCursor(iSchemaClass);
    if (cursor != null) {
      fetchValuesFromIndexCursor(cursor);
      return true;
    }
    return false;
  }
Use index to order documents by provided fields.

@param iSchemaClass where search for indexes for optimization.

@return true if execution was optimized