We’re overhauling Dgraph’s docs to make them clearer and more approachable. If
you notice any issues during this transition or have suggestions, please
let us know.
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.
Dgraph returns
null
values at the end of the results, irrespective of their
sort. This behavior is consistent across indexed and non-indexed sorts.Sorted queries retrieve up to 1000 results by default. This can be changed
with first.