Created
July 2, 2018 14:45
-
-
Save Sangarshanan/9f3d8f3ccc8ceb4bde6ab04c03d62592 to your computer and use it in GitHub Desktop.
This file contains 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
When you wanna sort | |
10 2 5 | |
7 1 0 | |
9 9 9 | |
1 23 12 | |
6 5 9 | |
with respect to element 1 (2,1,9,23,5) | |
print(sorted(rows, key=lambda row: int(row.split()[1]))) | |
key => specifies which elemsnt of a list to sort with respect to | |
7 1 0 | |
10 2 5 | |
6 5 9 | |
9 9 9 | |
1 23 12 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment