Convert type while sorting


(Lu Tang) #1

I’m using a Dgraph instance that stores all kinds of data in string format. For example, a float value 1234.56 is actually “1234.56”. When I orderdesc, it’s acutally compared as string type, i.e. from the starting characters. So I get “987” in front of “1234.56”. I’m wondering if I can force type change in orderdesc?


(Michel Conrado) #2

The order will be guide by the type previously defined. Afaik there’s no way to use float ordering as you need in a string type.

The pattern of string ordering is “123…ABC…abc” and then lexicographical ordering.


(Lu Tang) #3

Thanks! Then I won’t waste time on query, instead gonna change the dgraph type.