Rehceb Rotkiv schrieb:
> can I sort a multidimensional array in Python by multiple sort keys? A 
> litte code sample would be nice!

You can pass a function as argument to the sort method of a list.
The function should take two arguments and return -1, 0 or 1 as
comparison result. Just like the cmp function.

This will objects in list obj_lst by their id attributes:

def sorter(a, b):
    return cmp(a.id, b.id)

obj_lst.sort(sorter)

Thomas
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to