pyassistant

Sort words by vowel count (descending, stable)

Given a list of words (strings), return a new list where the words are sorted in descending order by the number of vowels they contain. Vowels are 'a', 'e', 'i', 'o', 'u' (treat letters case-insensitively). If two words have the same vowel count, preserve their original relative order (stable sort).

Example:

Input:
(['apple', 'pear', 'banana', 'grape'])
Output:
['banana', 'apple', 'grape', 'pear']

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.