[C++/Java/Python] || Easy and Beginners Friendly || Sort
\n# Approach\n Describe your approach to solving the problem. \nThe approach is to first identify the vowels in the input string s and store them along with the
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe approach is to first identify the vowels in the input string `s` and store them along with their positions in two separate vectors, `vow` and `pos`, respectively. Then, the code sorts the `vow` vector to arrange the vowels in ascending order. After that, a new string `answer` is created, initially set to the `same content as the input string s`. \n\nFinally, the code replaces the characters at the positions stored in the `pos` vector with the sorted vowels from the vow vector. The resulting modified string with the sorted vowels is returned as the output of the function.\n\n# Complexity\n- Time complexity: `O(n*logn)`\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: `O(n)`\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# C++ Code\n```\nclass Solution {\npublic:\n    string sortVowels(string s) {\n        int n = s.size();\n        vector<char> vow;\n        vector<int> pos;\n        for(int i=0;i<n;i++){\n            if(s[i] == \'a\' || s[i] == \'e\' || s[i] == \'i\' || s[i] ==\'o\' || s[i] == \'u\' || s[i] == \'A\' || s[i] == \'E\' || s[i] == \'O\' || s[i] == \'I\' || s[i] == \'U\') { // condition to check for vowel\n                vow.push_back(s[i]);\n                pos.push_back(i); //storing positions of vowel \n            }\n        }\n        sort(vow.begin(),vow.end());\n        string answer = s;\n        for(int i=0;i<pos.size();i++){\n            answer[pos[i]] = vow[i];\n        }\n        return answer;\n    }\n};\n```\n# java\n```\nclass Solution {\n    public String sortVowels(String s) {\n        int n = s.length();\n        ArrayList<Character> vow = new ArrayList<>();\n        ArrayList<Integer> pos = new ArrayList<>();\n        \n        for (int i = 0; i < n; i++) {\n            char ch = s.charAt(i);\n            if (ch == \'a\' || ch == \'e\' || ch == \'i\' || ch == \'o\' || ch == \'u\' || \nch == \'A\' || ch == \'E\' || ch == \'I\' || ch == \'O\' || ch == \'U\') { // condition to check for vowel\n                vow.add(ch);\n                pos.add(i); // storing positions of vowel\n            }\n        }\n        \n        Collections.sort(vow);\n        \n        char[] answer = s.toCharArray();\n        for (int i = 0; i < pos.size(); i++) {\n            answer[pos.get(i)] = vow.get(i);\n        }\n        \n        return new String(answer);\n    }\n}\n```\n# Python\n```\nclass Solution:\n    def sortVowels(self, s: str) -> str:\n        vow = []\n        pos = []\n        \n        for i, ch in enumerate(s):\n            if ch.lower() in {\'a\', \'e\', \'i\', \'o\', \'u\'}:\n                vow.append(ch)\n                pos.append(i)\n        \n        vow.sort()\n        answer = list(s)\n        \n        for i, v in zip(pos, vow):\n            answer[i] = v\n        \n        return \'\'.join(answer)\n```
['Sorting', 'Python', 'C++', 'Java']