I have a list like this
[[7, 6, 8], [1, 10], [3, 10], [7, 8], [7, 4], [9, 4], [5, 8], [9, 8]]
And I want the output to look something like this:
[[7, 6, 8],[1, 10],[3, 10],[9, 4],[5, 8]]
Where the algorithm should remove duplicates based on the first element in the inner list eg '7','1', '3'
etc. while prioritizing inner list's length, i.e. shorter should be removed first.
I found something similar here and here on how to do the first part of the question using this:
dict((x[0], x) for x in any_list).values()
but I don't know how to prioritize the length.