I am currently trying to sort a list such as the following. I need to sort the lists in order of the second element in each sub-list.
chars = [['Andrew', '1'], ['James', '12'], ['Sam', '123'], ['Zane', '2']]
I am currently using this command:
chars = sorted(chars, key=itemgetter(1))
My Ideal output would be:
chars = [['Andrew', '1'], ['Zane', '2'], ['James', '12'], ['Sam', '123']]