q(func: ..., orderasc: predicate)
q(func: ..., orderdesc: val(varName))
predicate (orderdesc: predicate) { ... }
predicate @filter(...) (orderasc: N) { ... }
q(func: ..., orderasc: predicate1, orderdesc: predicate2)
int
, float
, String
, dateTime
, default
Results can be sorted in ascending order (orderasc
) or descending order
(orderdesc
) by a predicate or variable.
For sorting on predicates with sortable indices,
Dgraph sorts on the values and with the index in parallel and returns whichever
result is computed first.
null
values at the end of the results, irrespective of their
sort. This behavior is consistent across indexed and non-indexed sorts.