While working with SQL today we found out that SQL does not sort our strings in a column as we would expect.
This is our list of datasets: (The URLs are shortened to prevent abuse)
http://10.10.14
http://192.168.
https://m.hanno
https://online.
https://online-
https://owi-000
https://owi2.su
https://owi2-00
https://owi2-71
https://owi-700
https://owi-702
https://owi-703
https://owi-704
https://owi-707
https://owi-708
https://owi-710
https://owi-711
https://owi-712
https://owi-713
https://owi-714
https://owi-715
https://owi-716
https://owi-717
https://owigo.n
https://owigosm
https://owigow.
The owi2-URLs are directly behind owi-000. However it should be behind owi-717 or before owi-000, but definitely not in between.
...
https://owi-000
https://owi2.su
https://owi2-00
https://owi2-71
https://owi-700
...
This is how we'd expect the results. The minus comes before the 2 in ASCII and many other character encodings. Therefore all URLs with owi2 should follow after owi-.
...
https://owi-717
https://owi2.su
https://owi2-00
https://owi2-71
https://owigo.n
...
We copied all the URLs in MS Excel and to our surprise we got the same results. So we checked the strings to make sure no non-printing-character is causing the issue. And in fact, we found no non-printing-character using Notepad++.
Our question is: Why is SQL sorting our URLs the way it does?