sort method

QueryBuilder sort(
  1. String fieldName,
  2. Direction sortDirection
)

Sorts the returned objects by the value of the specified field and sort direction

If multiple sort method calls are chained then each call is concatenated to a list, so that you can perform sorting by multiple fields.

fieldName The name of the field that will be used in sorting the returned objects. The field name can be in dot-notation to specify sub-object fields (e.g., field.subField)

sortDirection Sort direction whether ascending or descending

Returns the QueryBuilder itself so that you can chain other methods

Implementation

QueryBuilder sort(String fieldName, Direction sortDirection) {
  checkRequired('sort fieldName', fieldName);

  if (_action.sort != null) {
    _action.sort!.add(SortEntry(fieldName, sortDirection));
  } else {
    _action.sort = [SortEntry(fieldName, sortDirection)];
  }

  return this;
}