Yes I know.. Python 2.3... unfortunately our development servers are RedHat and that is the default version installed on them and apparently, upgrading can cause system failures (trying to figure out a work around to run multiple versions of python, but not there yet) in the mean time... I need see if any one can help me with sorting a multidimensiona l list by certain elements with in that list. I've read about Schwartzian Transform in Python? but for the life of my don't completely understand it. I have a M-D list that looks something like this
<COL0 , COL1 , COL2 , COL3 , COL4 , COL5>
0001 , 4 , 0.34 , 3 , 15 , 25.3
0001 , 4 , 0.34 , 2 , 10 , 20.2
0002 , 4 , 0.32 , 6 , 11 , 20.1
0001 , 4 , 0.34 , 3 , 24 , 21.6
0001 , 4 , 0.34 , 1 , 15 , 20.3
I need to sort by COL0, COL3, COL4 & COL5
i know in 2.6 i can just sort and use a key definition to define what columns i need to sort by...but in 2.3 key was not yet around...
here is something else i was trying where a = the MD list, i read you could sort one list of value by another list... doesn't work though... well... the sort of c, works just fine but the sort of e does not and that is what i need...
Thanks ahead of time to any help and or suggestions!
Cheers,
Eric
<COL0 , COL1 , COL2 , COL3 , COL4 , COL5>
0001 , 4 , 0.34 , 3 , 15 , 25.3
0001 , 4 , 0.34 , 2 , 10 , 20.2
0002 , 4 , 0.32 , 6 , 11 , 20.1
0001 , 4 , 0.34 , 3 , 24 , 21.6
0001 , 4 , 0.34 , 1 , 15 , 20.3
I need to sort by COL0, COL3, COL4 & COL5
i know in 2.6 i can just sort and use a key definition to define what columns i need to sort by...but in 2.3 key was not yet around...
here is something else i was trying where a = the MD list, i read you could sort one list of value by another list... doesn't work though... well... the sort of c, works just fine but the sort of e does not and that is what i need...
Code:
for b in a:
line = str(a[i][0]) + ',' + str(a[i][3]) + ',' + str(a[i][4]) + ',' + str(a[i][5])
c.append(line.split(','))
d.append(a)
i = i + 1
e = zip (c,d)
e.sort()
c.sort()
out = [x[1] for x in e]
print out
print c
Cheers,
Eric
Comment