[Tutor] Sorting multiple sequences

Dinesh B Vadhia dineshbvadhia at hotmail.com
Sat Mar 12 00:39:06 CET 2011

I want to sort two sequences with different data types but both with an equal number of elements eg.

f = [0.21, 0.68, 0.44, ..., 0.23]
i = [6, 18, 3, ..., 45]

The obvious solution is to use zip ie. pairs = zip(f,i) followed by pairs.sort().  This is fine but my sequences contain 10,000+ elements and the sort is performed thousands of times.  Is there a faster solution?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110311/cda1bfd3/attachment.html>

More information about the Tutor mailing list