C++ | For beginners | Sort ASCII
Approach\nSimply store the vowels in a vector and then sort them. Iterate across the string again and when a vowel is encoutered, call the sorted vector and app
# Approach\nSimply store the vowels in a vector and then sort them. Iterate across the string again and when a vowel is encoutered, call the sorted vector and append to the sting.\n\n# Complexity\n- Time complexity:\n$O(nlogn)$\n\n- Space complexity:\n$O(n)$\n\n# Code\n```\nclass Solution {\npublic:\n    string sortVowels(string s) {\n        // All vowels\n        vector<char> vow = {\'a\', \'e\', \'i\', \'o\', \'u\', \'A\', \'E\', \'I\', \'O\', \'U\'};\n        string ans;\n        // vector to store vowels\n        vector<char> store;\n        // Iterate the string\n        for(char c: s){\n            // If c is a vowel, append to store\n            if(find(vow.begin(), vow.end(), c) != vow.end()){\n                store.push_back(c);\n            }\n        }\n        // sort all vowels with increasing ASCII\n        sort(store.begin(), store.end());\n\n        int idx = 0;\n        for(char c: s){\n            // When a vowel appears, call the sorted vector\n            if(find(vow.begin(), vow.end(), c) != vow.end()){\n                ans += store[idx++];\n            }\n            else    ans += c;\n        }\n\n        return ans;\n    }\n};\n```
['C++']