0

Alphabetizing characters

https://code.sololearn.com/cZ7SlU30tiIS/#py I recently code that arranges words alphabetically and numbers numerically. I was then curious how it would run with other symbols like "!, @, #, $, %, etc." and I found that it does sort them but in a way I do not see the pattern. As of right now I am thinking it might be sorted numerically by the binary code corresponding to that symbol. Does anyone know exactly what basis it is sorting these inputs? You can try it yourself if you wish.

6th Apr 2020, 1:13 AM
Andrew Johnson
Andrew Johnson - avatar
2 Antworten
+ 1
sort default to lexicographic order, wich mean based on unicode (ascii in py2) values of chars... there's nothing here such as a 'QWERTY pattern' (wich is related to key ordering on a keyboard)
6th Apr 2020, 7:35 AM
visph
visph - avatar
0
I am still not sure I understand. I ran the code with an input of ! @ # (first three characters on the number row) and it returned it as follows: ! # @. Or am i misunderstanding the QWERTY pattern? haha
6th Apr 2020, 2:27 AM
Andrew Johnson
Andrew Johnson - avatar