Skip to content

Instantly share code, notes, and snippets.

@alothings
Created April 25, 2017 19:15
Show Gist options
  • Save alothings/e12f4a6ae7ca0a1c9326f7f57acd810c to your computer and use it in GitHub Desktop.
Save alothings/e12f4a6ae7ca0a1c9326f7f57acd810c to your computer and use it in GitHub Desktop.
def func(row):
return int(row.split()[k])
if __name__ == '__main__':
n, m = map(int, input().split())
rows = [input() for _ in range(n)]
k = int(input())
# for row in sorted(rows, key=lambda row: int(row.split()[k])): #works
for row in sorted(rows, key=func(row)): #doesn't work
print(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment