Check out example codes for "sort list of lists by first element". It will help you in understanding the concepts better.

Code Example 1

>>> lis = [[1,4,7],[3,6,9],[2,59,8]]
>>> sorted(lis, key=lambda x: x[0])
[[1, 4, 7], [2, 59, 8], [3, 6, 9]]

Learn ReactJs, React Native from akashmittal.com