I know this sounds trivial, but I did not understand that the sort() function of Python was weird. I have a list of "numbers" that are actually in string form, so I convert them to ints first and then try to sort.
list1=["1","10","3","22","23","4","2","200"] for item in list1: item=int(item) list1.sort() print list1
Gives me:
['1', '10', '2', '200', '22', '23', '3', '4']
I want to
['1','2','3','4','10','22','23','200']
I looked at some algorithms related to sorting numeric sets, but the ones I found include sorting alphanumeric sets.
I know this is probably not a problem, but google and my tutorial do not offer anything more or less useful than the .sort() function.
python sorting
Brian Aug 6 '10 at 17:17 2010-08-06 17:17
source share