The list type in Dgraph behaves like an unordered set (i.e. does not guarantee order).
Primitive lists do not permit sorting. Instead, we can create separate nodes for each fact:
{
set {
_:f1 <description> "test fact #1" .
_:f2 <description> "test fact #2" .
_:f3 <description> "test fact #3" .
_:p1 <has_fact> _:f1 .
_:p1 <has_fact> _:f2 .
_:p1 <has_fact> _:f3 .
}
}
Now, we can easily sort the output:
{
node(func: uid(0x6)) {
has_fact(orderasc: description) {
description
}
}
}