sort list multilevel ?

got some list like this

unique val = [0, 1, 2, 4, 6, 8, 14, 10, 12, 18, 20, 22, 34, 24, 16, 26, 28, 30,
32, 36]

unique2 val = [[0, 1], [1, 1], [2, 205], [4, 202], [6, 299], [8, 101], [14, 54],
[10, 119], [12, 105], [18, 40], [20, 15], [22, 16], [34, 2], [24, 15], [16, 33],
[26, 3], [28, 5], [30, 11], [32, 1], [36, 1]]

is there a way to sort function of the first number in the second level ?
at end of line I have 6 8 14 10 ect,
so not in order

thanks

val.sort()

but this will sort only at first level not to the second level !

with multi level it doe snot know what to sort
or is there a more advance sort that can deal with multi level sort ?

I could create a for loop to create a new list using index
but hoping there is one command existing for that !

found this
https://docs.python.org/3/howto/sorting.html?highlight=sort

but seems to work with tuple not list !

thanks

if you wanted to sort by the 2nd nested value, do

from operator import itemgetter
sorted(val, key=itemgetter(1))

Still can’t see how this is related to Blender in anway… you should refer to the python docs and stackexchange.