sorting two corresponding lists?

Esmail ebonak at hotmail.com
Mon Apr 20 12:57:18 EDT 2009


Hi Diez,

Thanks for this, I had seen zip() before but had no idea
really what it does, this will serve as good motivation to
find out more.

I'm amazed at what this language can do (and the helpfulness
of the people on the list here).

Best,
Esmail

Diez B. Roggisch wrote:

> items = zip(*sorted(zip(values, items)))[1]
> 
> To better understand this please note that
> 
> a = [1, 2]
> b = [3, 4]
> 
> zip(*zip(a, b)) == a, b
> 
> or, in other words, zip(*argument) is the inverse of an argument created by
> zip (under the assumption the a and b have equal length)
> 
> Diez
> --
> http://mail.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list