Question: Honestly it is really hard to explain what I am trying to do because I can't think of words that would help me describe it. Anyway, the problem is that I want to sort a list of lists:

```
[['a', [10, 6, 5]], ['b', [7, 4, 2]], ['c', [10, 6, 4]], ['d', [7, 3, 2]]]

```

This is an example of the list I am trying to sort. The strings are pupil names and the lists with three integers in them are the scores. I want to sort this list highest to lowest using the scores but I want to sort it so if two lists have the same first integer (E.G):

```
[7, 4, 2] and [7, 3, 2]

```

then it should decide which one should be higher by the next integer. I have tried many different methods but from what I have attempted none of them work. Its also been hard trying to find an answer as I do not know exactly how to explain my issue, although I hope what I have said above has given enough explanation to my problem.

My code if you need to look at it:
[MY CODE](http://pastebin.com/bLXFUQtJ)

Answer: 
You can use the `key` argument of the `sorted` function, and sort by the second element of each sublist. This will sort from element 0 to element N for each sublist. And the `reverse` argument is so you can sort highest to lowest (instead of the default lowest to highest)

```
>>> l = [['a', [10, 6, 5]], ['b', [7, 4, 2]], ['c', [10, 6, 4]], ['d', [7, 3, 2]]]
>>> sorted(l, key = lambda i: i[1], reverse=True)
[['a', [10, 6, 5]], ['c', [10, 6, 4]], ['b', [7, 4, 2]], ['d', [7, 3, 2]]]

```

You can also replace the `lambda` with `operator.itemgetter(1)` for the key argument as @ThiefMaster pointed out.
You simply specify a key function that returns all the keys you need. In your case the second element of each list (e.g. `[10, 6, 5]`) does the job since comparing lists compares them element by element.

```
from operator import itemgetter
sorted(whatever, key=itemgetter(1), reverse=True)

```

`itemgetter(1)` is the same as `lambda x: x[1]` but more performant (since it's implemented in Python's C code instead of in Python code).