I have a list like this:
[
[
['KAD', 'PENGENALAN'],
['0.95', '0.98'],
[[106, 16, 202, 48], [214, 14, 524, 50]],
[106, 214]
],
[
['word1', 'word2', 'word3'],
['0.95', '0.98', '0.99'],
[[222, 16, 202, 48], [55,14, 524, 50]], [89, 14, 524, 50]]
[222, 55, 89]
]
]
I want to sort items per line by 4th element.
4th element is [106, 214]
and [222, 55, 89]
First list is already sorted according to 4th element. I want to sort 2nd list.
In the second list, I want to sort by small to big. I want to sort using [222,55,89]
Expected output is:
[
[
['KAD', 'PENGENALAN'],
['0.95', '0.98'],
[[106, 16, 202, 48], [214, 14, 524, 50]],
[106, 214]
],
[
['word2', 'word3', 'word'],
['0.98', '0.99','0.95'],
[[55,14, 524, 50]], [89, 14, 524, 50],[222, 16, 202, 48]]
[55, 89,222]
]
]
I don't know how I can do this. But can I use zip()
and sort? Just giving you some ideas