I have an array that I want to sort alphabetically but also by the number at the end.
"SELECT DISTINCT Number FROM database WHERE 1 Order By Number ASC";
Here is how it currently sorts:
Number 1
Number 10
Number 11
Number 2
Number 3
Number 4
Number 5
Number 6
Number 7
Number 8
Number 9
The End
This is how I want it to sort:
Number 1
Number 2
Number 3
Number 4
Number 5
Number 6
Number 7
Number 8
Number 9
Number 10
Number 11
The End
Add another sort condition:
Order By LENGTH(Number), Number;
This works because a longer number is also a bigger number; for numbers of the same length, you can make a textual comparison, because '0' < '1' .... < '9'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With