I have a list of nested lists:
e = [['Tina', 37.2], ['Harsh', 39], ['Harry', 37.21], ['Berry', 37.21], ['Akriti', 41]]
How do you sort by numerical value, yet the names 'follow' the 'grade'? I could use dict, but I think it misses the point.
In your example Harry and Berry have the same value.
If you want ties to be sorted by name, a variation of the answers you got already would be something like this:
e = [['Tina', 37.2], ['Harsh', 39], ['Harry', 37.21], ['Berry', 37.21], ['Akriti', 41]]
e.sort(key=lambda x:(x[1], x[0]))
print(e)
#[['Tina', 37.2], ['Berry', 37.21], ['Harry', 37.21], ['Harsh', 39], ['Akriti', 41]]
lambda x: (x[1], x[0])?