Skip to content

Instantly share code, notes, and snippets.

@ixtel
Forked from bbengfort/mixer.py
Created October 19, 2015 12:58
Show Gist options
  • Save ixtel/d5c9a632a9650b36c795 to your computer and use it in GitHub Desktop.
Save ixtel/d5c9a632a9650b36c795 to your computer and use it in GitHub Desktop.
Sorting a list according to the first.
from operator import itemgetter
names = ['a', 'c', 'd', 'b']
runes = [1, 2, 3, 4]
def mixer(a, b):
"""
Returns the second list sorted according to the first
"""
return [z[1] for z in sorted(zip(a, b), key=itemgetter(0))]
print mixer(names, runes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment