Created
October 26, 2020 17:14
-
-
Save imnuvi/70b5a22582915dbba5dae22859328528 to your computer and use it in GitHub Desktop.
sorting based on different indices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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