I suspect the problem is caused by a non-obvious detail that definitely needs an usability improvement. Similarly to filters, which are split in "standard" Filters and Group Filters, there's also the notion of Group Sorts and "standard" Sorts, although that's not reflected in the editor. And when an Aggregate has groups, "standard" Sorts are completely ignored...
To see if that's your scenario, try this:
If it doesn't, then your sort is actually a "standard" Sort and is being ignored.
To fix it, just delete the Sort and add a new Dynamic Sort with the same expression as before. Since the Aggregate is grouped, this will create a Grouped Sort.
Let me know if this helped.
Thanks Paulo! It worked. I had to delete the sort and add it again, but then it was in the executed SQL.