Skip to content

Instantly share code, notes, and snippets.

@vitalbh
Created January 27, 2012 16:47
Show Gist options
  • Select an option

  • Save vitalbh/1689718 to your computer and use it in GitHub Desktop.

Select an option

Save vitalbh/1689718 to your computer and use it in GitHub Desktop.
python sorting - organizando uma lista em uma ordem alfabética pré-definida
alfabeto = "zyxwvutsrqpomnlkjihgfedcba"
s = ['asdf', 'werwer', 'asgfd','wesasd','yasdfas','zsadf']
print sorted(s, key=lambda w: [alfabeto.index(i) for i in w])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment