Skip to content

Instantly share code, notes, and snippets.

@ripiuk
Created April 1, 2018 13:13
Show Gist options
  • Save ripiuk/55df60be1823a2e1ff932f916e2f562d to your computer and use it in GitHub Desktop.
Save ripiuk/55df60be1823a2e1ff932f916e2f562d to your computer and use it in GitHub Desktop.
Sort words by the number of vowels
data = ['some str', 'longer str', 'the biggest string', 'small one']
vowels = 'eyuioa'
data.sort(key=lambda x: sum(ch in vowels for ch in x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment