I have a list a
containing rows (also lists) with three elements each. I want to sort those according to the values in a list b
in ascending order. I tried the following:
a = [[1,2,3],['hi','foo','fi'],[7,8,9]]
print(a)
b = [0.3,3,0.6]
keydict = dict(zip(a,b))
a.sort(key=keydict.get)
However im getting the error:
TypeError: unhashable type: 'list'
in the line with keydict = dict(zip(a,b))
.
I expect to get this:
a = [[1,2,3],[7,8,9],['hi','foo','fi']]
What could i do to make it right?