for (int depth = 0; depth < criteria.getElements().size(); depth++) {
Field field = schema.getField(depth);
Field.Type type = field.getType();
SortElement sortElement = criteria.getElements().get(depth);
Order sort = sortElement.getOrder();
RawComparator comparator = sortElement.getCustomComparator();
// Control for nulls, if field is nullable.
if (field.isNullable()) {
Criteria.NullOrder nullOrder = sortElement.getNullOrder();