If I have a list defined as such:
myresults = [
[1,"A",2],
[2,"Z",1],
[3,"J",0]
]
and I need to sort the list. I know I can use the sorted()
function with a key function lambda=x:x[i]
where i
is the position to sort in a list. So this should work:
print sorted(myresults, key=lambda x:x[1])
and give back a list sorted on the 2nd column in the sub list.
How would you adapt a quicksort algorithm to handle a multi-dimensional list?