Skip to content

Instantly share code, notes, and snippets.

@imnuvi
Created October 26, 2020 17:14
Show Gist options
  • Select an option

  • Save imnuvi/70b5a22582915dbba5dae22859328528 to your computer and use it in GitHub Desktop.

Select an option

Save imnuvi/70b5a22582915dbba5dae22859328528 to your computer and use it in GitHub Desktop.
sorting based on different indices
# code to sort a list based on second index
lst = [[1,"e"],[2,"t"],[9,"a"][5,"r"][4,"b"]]
ans = sorted(lst,key=lambda x: (x[1], x[0]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment