code: public <K> SortedGrouping<T> sortGroup(KeySelector<T, K> keySelector, Order order) {
  		if (!(this.getKeys() instanceof Keys.SelectorFunctionKeys)) {
  			throw new InvalidProgramException("KeySelector group-sorting keys can only be used with KeySelector grouping keys.");
  		}
  
  		TypeInformation<K> keyType = TypeExtractor.getKeySelectorTypes(keySelector, this.inputDataSet.getType());
  		SortedGrouping<T> sg = new SortedGrouping<T>(this.inputDataSet, this.keys, new Keys.SelectorFunctionKeys<T, K>(keySelector, this.inputDataSet.getType(), keyType), order);
  		sg.customPartitioner = getCustomPartitioner();
  		return sg;
  	}
docs: Sorts elements within a group on a key extracted by the specified {@link org.apache.flink.api.java.functions.KeySelector}
  in the specified {@link Order}.
  
  <p>Chaining {@link #sortGroup(KeySelector, Order)} calls is not supported.
  
  @param keySelector The KeySelector with which the group is sorted.
  @param order The Order in which the extracted key is sorted.
  @return A SortedGrouping with specified order of group element.
  
  @see Order