Skip to content

Instantly share code, notes, and snippets.

@bbengfort
Created July 9, 2014 18:10
Show Gist options
  • Save bbengfort/93f7b59f6409a354cdf9 to your computer and use it in GitHub Desktop.
Save bbengfort/93f7b59f6409a354cdf9 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