Java Solution | O(n) | With Explanation
Step 1: Vowel Setup\n- Utilize the string "AEIOUaeiou" to establish the order of vowels based on ASCII values.\n- Three helper methods are employed:\n  1. To ch
**Step 1: Vowel Setup**\n- Utilize the string "AEIOUaeiou" to establish the order of vowels based on ASCII values.\n- Three helper methods are employed:\n  1. To check if a character is a vowel.\n  2. To get the index of the vowel in the array.\n  3. To retrieve the vowel character based on its index.\n\n**Step 2: Counting Vowels**\n- Iterate through the input string `s`. Use a vowel array to keep track of the count of each vowel encountered.\n- For each vowel in the string, increment its corresponding count in the vowel array. Non-vowel characters are ignored in this step.\n\n**Step 3: Reconstructing with Sorted Vowels**\n- Create a `StringBuilder` to efficiently construct the output string.\n- Traverse the input string again. For each vowel, append the next available vowel from the vowel array to the `StringBuilder`. For non-vowel characters, append them directly as they are.\n- This process ensures that vowels in the output are sorted according to their occurrence and ASCII order.\n\n**Step 4: Final Output**\n- Convert the content of the `StringBuilder` into a string and return it as the final result.\n- This approach efficiently sorts the vowels in the string while maintaining the original order of non-vowel characters.\n\n```\nclass Solution {\n    public String sortVowels(String s) {\n        int[] vowels = new int[10]; // Array to count vowels\n        \n        for (char c : s.toCharArray()) {\n            int idx = getVowelIndex(c);\n            if (idx != -1) {\n                vowels[idx]++;\n            }\n        }\n\n        StringBuilder sb = new StringBuilder();\n        for (char c : s.toCharArray()) {\n            if (isVowel(c)) {\n                for (int i = 0; i < vowels.length; i++) {\n                    if (vowels[i] > 0) {\n                        sb.append(getVowelFromIndex(i));\n                        vowels[i]--;\n                        break;\n                    }\n                }\n            } else {\n                sb.append(c);\n            }\n        }\n\n        return sb.toString();\n    }\n\n    private boolean isVowel(char c) {\n        return "AEIOUaeiou".indexOf(c) >= 0;\n    }\n\n    private int getVowelIndex(char c) {\n        String vowels = "AEIOUaeiou";\n        return vowels.indexOf(c);\n    }\n\n    private char getVowelFromIndex(int idx) {\n        String vowels = "AEIOUaeiou";\n        return vowels.charAt(idx);\n    }\n}\n\n```\n\nIf you found it helpful, please consider giving it an upvote! It\'ll motivate me to share more solutions in the future. If you have any questions or suggestions, please let me know. Happy coding
['Java']