On 02/11/11 16:58, Dave Angel wrote:

sorted(results)
['10B', '1A', '2C', '3D']

as [ '1A', '2C', '3D','10B']


Essence of the answer is you can supply a key=myfunc argument to
sorted(). Then it's up to you what you put in that function. It sounds
like you want to convert any leading digits to an int, and return that int.

Or in your case it might be hex in which case convert the whole string using int and specify the base to be 16...

>>> int('1A',16)
26

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to