Sort words in a string based on their vowel number

You will want to create an array of structs that hold a pointer to the word and then the number of vowels in each word. Something like:

struct vowelcnt {
    char *word;
    int numvowels;

Then sort the array of structs (descending order based on numvowels. Then simply loop through the sorted structs outputting the word which would give you the words sorted in order of the number of vowels contained. Hope that helps.

Leave a Comment