Skip to content

Instantly share code, notes, and snippets.

@sameerg07
Created June 13, 2021 07:40
Show Gist options
  • Save sameerg07/71a47152e29f4c8db5df8098b40773d7 to your computer and use it in GitHub Desktop.
Save sameerg07/71a47152e29f4c8db5df8098b40773d7 to your computer and use it in GitHub Desktop.
sort list of tuples with key
import ast,sys
input_str = input()
input_list = ast.literal_eval(input_str)
sorting_choice = input()
# Your code goes here
print(sorted(input_list,key=lambda x: x[int(sorting_choice)-1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment