0

I'm trying to sort a dictionary of lists by the first, then second list entries. From the Sorting how-to, I'm trying to apply the operator, but am doing it wrong. Any and all help is much appreciated!

my_dict = { 111: [50, 2, 34], 122: [50 , 4, 45], 133: [40, 1, 12], 144: [20, 5, 7] }

s = sorted(my_dict, key = itemgetter(0), reverse=True)
sorted(s, key=itemgetter(1))

giving the error below. I'm still fairly new at this and don't understand the error fully.

    s = sorted(my_dict, key = itemgetter(0), reverse=True)
TypeError: 'int' object is not subscriptable
Detterman
  • 17
  • 4

0 Answers0