code: public void setOrderBy(OrderBy ordering) throws TupleMRException {
      failIfNull(ordering, "OrderBy can't be null");
      failIfEmpty(ordering.getElements(), "OrderBy can't be empty");
      failIfEmpty(schemas, "Need to specify source schemas");
      failIfEmpty(groupByFields, "Need to specify group by fields");
      if (schemas.size() == 1) {
        if (ordering.getSchemaOrderIndex() != null) {
          throw new TupleMRException(
              "Not able to use source order when just one source specified");
        }
      }
      Schema firstSchema = schemas.get(0);
  
      for (SortElement sortElement : ordering.getElements()) {
        if (!fieldPresentInAllSchemas(sortElement.getName())) {
          throw new TupleMRException("Can't sort by field '" + sortElement.getName()
              + "' . Not present in all sources");
        }
        if (!fieldSameTypeInAllSources(sortElement.getName())) {
          throw new TupleMRException("Can't sort by field '" + sortElement.getName()
              + "' since its type differs among sources");
        }
  
        if (sortElement.getCustomComparator() != null) {
          Field field = firstSchema.getField(sortElement.getName());
          if (field.getType() != Type.OBJECT) {
            throw new TupleMRException("Not allowed to specify custom comparator for type=" + field.getType());
          }
        }
      }
      // group by fields need to be a prefix of sort by fields
      for (String groupField : groupByFields) {
        if (!ordering.containsBeforeSchemaOrder(groupField)) {
          throw new TupleMRException("Group by field '" + groupField
              + "' is not present in common order by before source order");
        }
      }
  
      this.commonOrderBy = ordering;
    }
docs: Sets the criteria to sort the tuples by. In a multi-schema scenario all the
  fields defined in the specified ordering must be present in every
  intermediate schema defined.
  
  @see OrderBy