On 9/24/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> hi,
>
> I have the following list -
>
> ["1", "11", "2", "22"]
>
> how do I sort it like this -
>
> ["1", "2", "11", "22"]
>

Hi,

>>> l = ["1", "11", "2", "22"]
>>> sorted(l, cmp = lambda x, y: cmp(int(x), int(y)))  # provide your
own compare function !
>>> l
['1', '2', '11', '22']

Cheers,

-- 
----
Amit Khemka
website: www.onyomo.com
wap-site: www.owap.in
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to