What you’re trying to do is a bit unclear to me. What’s the shape of the data you have initially, and what’s the shape of the data you’re trying to create?
You have a collection with a data array with keys which already look sorted. Are you trying to sort the keys in that array in a different way from what you’re showing?