orderBy method
Creates and returns a new Query that's additionally sorted by field, a String (dots separate nested
fields) or a FieldPath, in ascending order or, with descending, in descending order.
Implementation
Query<T> orderBy(Object field, {bool descending = false}) {
final FieldPath fieldPath;
if (field is FieldPath) {
fieldPath = field;
} else if (field is String) {
fieldPath = FieldPathInternal.fromArgument('orderBy', field);
} else {
throw ArgumentError.value(
field,
'field',
'orderBy() expects a String field or a FieldPath',
);
}
return _withQuery(
_builder.orderBy(query, fieldPath.internalPath, descending: descending),
);
}