Reputation: 534
I noticed that the ORDER BY clause orders text according to ASCII order, not alphabetically, like, for example, MySQL does.
In other words, this is how Neo4J would order properties:
Apple
Carrot
banana
And MySQL would order them like this:
Apple
banana
Carrot
What is the best way to get Neo4J to sort alphabetically? One way is to use upper (or lower) like this:
MATCH (e) RETURN e.name ORDER BY upper(e.name) ASC;
Another idea is to create a new property, nameSort, which is the same as the name property, but in upper (or lower) case.
Any other ways to do it? I would prefer to do something simple, like the Cypher modification above, rather than creating a new property, but I don't know what the performance implications are.
Upvotes: 1
Views: 690
Reputation: 71033
Neo4j performs lexicographic string ordering, which is what you're seeing. This is documented here. To achieve case-insensitive ordering, you'd need to implement this on your own (such as your suggestion for converting the case either during the query or when storing the property value).
Upvotes: 1