I have a couple of list in a list sorted like this:
L = [['b','4'].['a','7'],['c','2']]
I want to see if it is possible to arrange the list so that it looks bit like this:
L = [['a','7'],['b','4'],['c','2']]
The first character of each list is placed alphabetically. How might I go about doing this?
sorted(L)
gets the job done – Green Cloak Guy Aug 4 '20 at 18:56print(sorted(L, key=operator.itemgetter(0)))
– user13645394 Aug 4 '20 at 19:00key
function to do what you want. – martineau Aug 4 '20 at 19:33