human
Sort an Array of Strings according to the number of Vowels in them | Function to check the Vowel.
Returns count of vowels in str.
Check for vowel.
Function to sort the array according to the number of the vowels.
Vector to store the number of vowels with respective elements.
Inserting number of vowels with respective strings in the vector pair.
Sort the vector , this will sort the pair according to the number of vowels.
Print the sorted vector content.
Driver code"
How can the above be solved in Python?
 ... Write me a code to sort an Array of Strings according to the number of Vowels in them and the other steps required?
assistant
#Here is code to sort an Array of Strings according to the number of Vowels in them and the other steps required.
 def isVowel ( ch ) :
	ch = ch . upper ( ) ;
	return ( ch == ' A ' or ch == ' E ' or ch == ' I ' or ch == ' O ' or ch == ' U ' ) ;
def countVowels ( string ) :
	count = 0 ;
	for i in range ( len ( string ) ) :
		if ( isVowel ( string [ i ] ) ) :
			count += 1 ;
	return count ;
def sortArr ( arr , n ) :
	vp = [ ] ;
	for i in range ( n ) :
		vp . append ( ( countVowels ( arr [ i ] ) , arr [ i ] ) ) ;
	vp . sort ( )
	for i in range ( len ( vp ) ) :
		print ( vp [ i ] [ 1 ] , end = " ▁ " ) ;
if __name__ == " _ _ main _ _ " :
	arr = [ " lmno " , " pqrst " , " aeiou " , " xyz " ] ;
	n = len ( arr ) ;
	sortArr ( arr , n ) ;