How can group by part of key and order by other

can someone give example? how to emit multiple keys in this case and what group level should be set on query?

Query results are always sorted by key. So if you’re using a compound key for grouping, but you want the results ordered by some other criterion, you’ll have to read the results into an array and sort them in memory.