Need a strange sort method...
SpreadTooThin
bjobrien62 at gmail.com
Mon Oct 16 14:13:08 EDT 2006
I have a list and I need to do a custom sort on it...
for example:
a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order
def cmp(i,j): #to be defined in this thread.
a.sort(cmp)
print a
[1,4,7,10, 2,5,8, 3,6,9]
So withouth making this into an IQ test.
Its more like
1 4 7 10
2 5 8
3 6 9
Read that top to bottom from column 1 to column 4.
When you get to the bottom of a column move to the next column.
Get it?
More information about the Python-list
mailing list