[Tutor] Sorting multiple sequences

Emile van Sebille emile at fenx.com
Sat Mar 12 00:57:57 CET 2011

On 3/11/2011 3:39 PM Dinesh B Vadhia said...
> 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?

Sort only once?

If you describe your situation better you may get more helpful 
responses, but if you really want to sort 1000's of times I doubt 
there's anything mush faster that pairs.sort()...


More information about the Tutor mailing list