How to Sort this array
marco at sferacarta.com
Sat Oct 26 10:49:32 CEST 2002
On Sat, Oct 26, 2002 at 06:23:47AM +0000, Hai Wu 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?
array = [ x.split('_') for x in array ]
array = [ '_'.join(x) for x in array ]
If your list is big, it's better to avoid a custom cmp function, because
the function call overhead in python is heavy.
More information about the Python-list