[Tutor] How to numerically sort strings that start with numbers?

Pete O'Connell pedrooconnell at gmail.com
Tue Sep 14 02:11:05 CEST 2010


theList = ["21 trewuuioi","3zxc","134445"]
print sorted(theList)

Hi, the result of the sorted list above doesn't print in the order I
want. Is there a straight forward way of getting python to print
['3zxc','21 trewuuioi','134445']
rather than ['134445', '21 trewuuioi', '3zxc']?

Any help would be greatly appreciated
Pete


More information about the Tutor mailing list