How to Sort this array

Andreas Jung andreas at andreas-jung.com
Sat Oct 26 04:27:36 EDT 2002


something like that might work:

def sortfunc(a,b):
	return cmp(a.replace("_",""),b.replace("_",""))

yourlist.sort(sortfunc)

-aj

--On Samstag, 26. Oktober 2002 06:23 +0000 Hai Wu <haiwuhaiwu at hotmail.com> 
wrote:

> How to sort an array with numbers like 021025_11441 in it? It needs to be
> sorted first by the number before '_', then sorted by the number after
> '_'? How to do it using a customized sort function?
>
> Thanks,
>
>
>
>
>
> _________________________________________________________________
> Broadband? Dial-up? Get reliable MSN Internet Access.
> http://resourcecenter.msn.com/access/plans/default.asp
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list




    ---------------------------------------------------------------------
   -    Andreas Jung                     http://www.andreas-jung.com   -
  -   EMail: andreas at andreas-jung.com                              -
   -            "Life is too short to (re)write parsers"               -
    ---------------------------------------------------------------------





More information about the Python-list mailing list