Skip to content

Instantly share code, notes, and snippets.

@llctrautmann
Created June 7, 2023 09:17
Show Gist options
  • Select an option

  • Save llctrautmann/f5e86f1f5148211c95563842300f0687 to your computer and use it in GitHub Desktop.

Select an option

Save llctrautmann/f5e86f1f5148211c95563842300f0687 to your computer and use it in GitHub Desktop.
Sort list of lists by item in the inner list
from operator import itemgetter
data = [
5,
"Harry",
37.21,
"Berry",
37.21,
"Tina",
37.2,
"Akriti",
41,
"Harsh",
39
]
sorted(data, key=itemgetter(1)) # will sort by the floats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment