human
What is a code to modify string by rearranging vowels in alphabetical order at their respective indices and the other steps required given the following:
Modify string by rearranging vowels in alphabetical order at their respective indices | Function to arrange the vowels in sorted order in the string at their respective places.
Store the size of the string.
Stores vowels of string S.
Traverse the string , S and push all the vowels to string vow.
If vow is empty , then print S and return.
Sort vow in alphabetical order.
Traverse the string , S.
Replace S [ i ] with vow [ j ] iif S [ i ] is a vowel , and increment j by 1.
Print the string.
Driver Code"
Solution in Python:
assistant
#Here is code to modify string by rearranging vowels in alphabetical order at their respective indices and the other steps required.
 def sortVowels ( S ) :
	n = len ( S ) ;
	vow = " " ;
	for i in range ( n ) :
		if ( S [ i ] == ' a ' or S [ i ] == ' e ' or S [ i ] == ' i ' or S [ i ] == ' o ' or S [ i ] == ' u ' ) :
			vow += S [ i ] ;
	if len ( vow ) == 0 :
		print ( S , end = " " ) ;
		return ;
	vow = list ( vow ) ;
	vow . sort ( ) ;
	j = 0 ;
	for i in range ( n ) :
		if ( S [ i ] == ' a ' or S [ i ] == ' e ' or S [ i ] == ' i ' or S [ i ] == ' o ' or S [ i ] == ' u ' ) :
			S [ i ] = vow [ j ] ;
			j += 1 ;
	print ( " " . join ( S ) , end = " " ) ;
if __name__ == " _ _ main _ _ " :
	S = " geeksforgeeks " ;
	sortVowels ( list ( S ) ) ;