Order ascending by uid


Is it possible to order the results of a query by uid?
I’ve read somewhere in the documentation that lists like [uid] in dgraph are unsorted sets and by default they are ordered (descending) by uid. However if I try to order ascending the results I get

Message: : Cannot sort by unknown attribute uid

Is there any way to do it?

As far as I can tell, all unordered or without order will be ordered by uid. But UID ordering isn’t sorting order friendly. Cuz it is randomly assigned.

From Docs:

Note Without a sort order specified, the results are sorted by uid , which is assigned randomly. So the ordering, while deterministic, might not be what you expected. Source: https://docs.dgraph.io/query-language/#pagination

Query Example: A movie in each genre that has over 30000 movies. Because there is no order specified on genres, the order will be by UID.

That feels wrong. It is ascending by default.

You can’t explicitly set uid as order param. By it is already ordered by uid.


As usual, thanks for your answer @MichelDiz