I have this list A
:
A = ['-1', '-2', '-2', '1', '1', '10', '100', '20', '4']
If I put sorted(A)
I get this
['1', '1', '-1', '20', '4', '-2', '-2', '10', '100']
I tried this list:
lista = ['3', '2', '5', '6', '7']
and if I repeat this process, that is to say sorted(lista)
, I print it neat but, for some reason, with the negative numbers I have problems. I do not understand why Python no longer orders it properly.
What I needed was for me to organize a list of string numbers, without needing to return them whole and without using a cycle .
Any idea why it happens and if it can be solved?