```python
def reverse_vowels(str1):
    """
    Reverses only the vowels of a given string.
    """
    vowels = "aeiouAEIOU"
    s = list(str1)
    left, right = 0, len(s) - 1

    while left < right:
        # Find the leftmost vowel
        while left < right and s[left] not in vowels:
            left += 1
        
        # Find the rightmost vowel
        while left < right and s[right] not in vowels:
            right -= 1
            
        # Swap the vowels
        if left < right:
            s[left], s[right] = s[right], s[left]
            left += 1
            right -= 1
            
    return "".join(s)
```