code: private static <T extends Storable> OrderingList<T>
          expectedOrdering(StorageAccess<T> access, Filter<T> filter, OrderingList<T> ordering)
      {
          List<Filter<T>> split;
          if (filter == null) {
              split = Filter.getOpenFilter(access.getStorableType()).disjunctiveNormalFormSplit();
          } else {
              split = filter.disjunctiveNormalFormSplit();
          }
  
          Comparator comparator = CompositeScore.fullComparator();
  
          CompositeScore bestScore = null;
          for (StorableIndex<T> index : access.getAllIndexes()) {
              for (Filter<T> sub : split) {
                  CompositeScore candidateScore = CompositeScore.evaluate(index, sub, ordering);
                  if (bestScore == null || comparator.compare(candidateScore, bestScore) < 0) {
                      bestScore = candidateScore;
                  }
              }
          }
  
          // Reduce source ordering to that which can be handled for
          // free. Otherwise, a sort would be performed which is a waste of time
          // if some source results will later be filtered out.
          int handledCount = bestScore == null ? 0 : bestScore.getOrderingScore().getHandledCount();
          return ordering.subList(0, handledCount);
      }
docs: Examines the given ordering against available indexes, returning the
  ordering that the best index can provide for free.