sorting many arrays from one...

Shagshag13 shagshag13 at yahoo.fr
Tue Jul 9 07:18:28 EDT 2002


hello,

i'm looking for an "efficient" way of sorting many arrays driven by one, for example

drive = [1, 4, 2, 3]
other1 = [a, b, c, d]
other2 = [ k, j, h, l ]
other3 = [14, 18, 19, 11]

and i get :

drive = [1, 2, 3, 4]
other1 = [a, c, d, b]
other2 = [ k, h, l, j]
other3 = [14, 19, 11, 18]

by now i use a list (copy from 'drive') that i sort and then iterate to find index in 'drive' and build my others arrays,

but i'm asking if i shouldn't use a dict (for example { 1 : (a, k, 14) , 4 : (b, j, 18) ...) then sort keys and building arrays from
dict values...

but maybe you have betters ideas ?

thanks,

s13.





More information about the Python-list mailing list