code: public SortedGrouping<T> sortGroup(int field, Order order) {
  		
  		int pos;
  		
  		if (!dataSet.getType().isTupleType()) {
  			throw new InvalidProgramException("Specifying order keys via field positions is only valid for tuple data types");
  		}
  		if (field >= dataSet.getType().getArity()) {
  			throw new IllegalArgumentException("Order key out of tuple bounds.");
  		}
  		
  		int newLength = this.groupSortKeyPositions.length + 1;
  		this.groupSortKeyPositions = Arrays.copyOf(this.groupSortKeyPositions, newLength);
  		this.groupSortOrders = Arrays.copyOf(this.groupSortOrders, newLength);
  		pos = newLength - 1;
  		
  		this.groupSortKeyPositions[pos] = field;
  		this.groupSortOrders[pos] = order;
  		return this;
  	}
docs: Sorts {@link Tuple} elements within a group on the specified field in the specified {@link Order}.</br>
  <b>Note: Only groups of Tuple elements can be sorted.</b><br/>
  Groups can be sorted by multiple fields by chaining {@link #sortGroup(int, Order)} calls.
  
  @param field The Tuple field on which the group is sorted.
  @param order The Order in which the specified Tuple field is sorted.
  @return A SortedGrouping with specified order of group element.
  
  @see Tuple
  @see Order