I've done some research but could not find the way to order a table (list of lists) by a column following a specific order (i.e. given by a specific list).
I have a table made by a list of lists where each sublist represent a row of the table and each of its elements are the column values of that row.
My_table has 4 columns and I need to sort the table according to several options.
I am currently sorting it by the first column and then by the second column, as follows
My_table=sorted(My_table, key=lambda a: ( a, a))
maybe something like this?
order_of_3rd = [3,0,1,2] My_table.sort(key=lambda a: (a, order_of_3rd.index(a)))
Note: if you are just assigning the sorted list back to the original list, you may as well use the inplace list sort