Modify string by rearranging vowels in alphabetical order at their respective indices

Modify string by rearranging vowels in alphabetical order at their respective indices
Given a string S of length N, the task is to sort the vowels of the given string in alphabetical order at place them accordingly in their respective indices.
Examples:

Input: S = “geeksforgeeks”Output: geeksfergeoksExplanation:The vowels in the string are: e, e, o, e, eSort in alphabetical order: e, e, e, e, o and replace with the vowels present in original string.
Input: S = “people”Output: peeplo

Approach: The idea is to store all the vowels present in the string S in another string, say vow. Sort the string vow in alphabetical order. Traverse the string S from the start and replace S[i] with vow[j] if S[i] is a vowel, and incrementing j by 1. Follow the steps below to solve the problem:Below is the implementation of the above approach.

C++

#include
using namespace std;
  

void sortVowels(string S)
{
    
    int n = S.size();
  
    
    string vow = “”;
  
    
    
    for (int i = 0; i < n; i++) {            if (S[i] == 'a' || S[i] == 'e'             || S[i] == 'i' || S[i] == 'o'             || S[i] == 'u') {             vow += S[i];         }     }                  if (vow.size() == 0) {         cout