Sorting coordinates array

Peter Otten __peter__ at web.de
Fri Dec 19 06:29:26 EST 2003


Peter Otten wrote:

> This is a highly unoptimized version, but at least seems to do the job.

Slightly better:

>>> lst = a.tolist()
>>> lst
[[0, 0, 0], [0, 2, 1], [1, 1, 0], [0, 1, 1]]
>>> for item in lst: item.reverse()
...
>>> lst.sort()
>>> for item in lst: item.reverse()
...
>>> lst
[[0, 0, 0], [1, 1, 0], [0, 1, 1], [0, 2, 1]]
>>>

Peter




More information about the Python-list mailing list