cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Sorting issue for alhanumeric

Hello ,

When I am trying to sort by alphanumeric, it is not happening in proper manner.Please find below.Is it another way to sort alphanumeric?
match(n:t1) return n.qi,n.qd order by n.qi;
+----------------+
| n.qi | n.qd |
+----------------+
| "q1" | "q1" |
| "q10" | "q10" |
| "q11" | "q" |
| "q11b" | "q1" |
| "q12" | "q1" |
| "q13" | "q1" |
| "q1a" | "q1" |
| "q1b" | "q1" |
| "q2" | "q2" |
| "q3" | "q3" |
+----------------+

Out put should be like this:
+----------------+
| n.qi | n.qd |
+----------------+
| "q1" | "q1" |
| "q1a" | "q1" |
| "q1b" | "q1" |
| "q2" | "q2" |
| "q3" | "q3" |
| "q10" | "q10" |
| "q11" | "q" |
| "q11b" | "q1" |
| "q12" | "q1" |
| "q13" | "q1" |
+----------------+

1 REPLY 1

I do understand this is not what you wanted, but technically speaking in terms of alpha-numeric sorting it is sorting correctly.

q10 will below q2, because each character is compared in order that they occur. q1<q2
if the data was q02 and q10 it would have sorted q02<q10

For example, the data looked more like below I think it would sort the way you were hoping.


+----------------+
| n.qi | n.qd |
+----------------+
| "q01" | "q01" |
| "q01a" | "q01" |
| "q01b" | "q01" |
| "q02" | "q02" |
| "q03" | "q03" |
| "q10" | "q10" |
| "q11" | "q" |
| "q11b" | "q01" |
| "q12" | "q01" |
| "q13" | "q01" |
+----------------+