@Override
  public boolean isOrderByApplicableAtIndexLevel(ExecutionContext context,
      String canonicalizedOrderByClause) throws FunctionDomainException, TypeMismatchException,
      NameResolutionException, QueryInvocationTargetException {

    if (getPlanInfo(context).evalAsFilter) {
      PlanInfo pi = getPlanInfo(context);
      if (pi.indexes.size() == 1) {
        IndexProtocol ip = (IndexProtocol) pi.indexes.get(0);
        return ip.getCanonicalizedIndexedExpression().equals(canonicalizedOrderByClause)
            && ip.getType() != IndexType.PRIMARY_KEY && pi.isPreferred;
      }
    }
    return false;
  }
get the path to see if there's an index for, and also determine which CompiledValue is the key
while we're at it
geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledComparison.java