Python one-liner (code golf)
You can also make everything one line:
```python3
class Solution:
    def applyOperations(self, nums: List[int]) -> List[int]:
        return sorted(sum(((l:=len([*g]))//2*[k*2,0]+l%2*[k]for k,g in groupby(nums)),[]),key=not_)
```
You can also make everything one line:
```python3
class Solution:applyOperations=lambda _,n:sorted(sum(((l:=len([*g]))//2*[k*2,0]+l%2*[k]for k,g in groupby(n)),[]),key=not_)
```
['Sorting', 'Python', 'Python3']