[Tutor] Sorting 2-d data

Wayne srilyk at gmail.com
Sun Sep 13 04:37:15 CEST 2009


Hi,
I have a set of data that looks something like this:

3, 4, 3, 2, 1
2, 1, 1, 1, 1
4, 2, 2, 1, 2
1, 3, 1, 1, 1

I want to be able to sort it by the first column, keeping the rest of the
values in the same position relative to the original:

1, 3, 1, 1, 1
2, 1, 1, 1, 1
3, 4, 3, 2, 1
4, 2, 2, 1, 2

and I'm wondering if there are any included ways to sort data like this.
I've currently got a 2d list by columns, but I could easily convert that to
rows if it would work better.

I'm about to check if sorting a list of lists will work in that fashion.

Thanks for any help/advice,
Wayne

-- 
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn’t. - Primo Levi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090912/caa4785c/attachment.htm>


More information about the Tutor mailing list