I have a map with a compound key which naturally sorts in an ascending order as: [No, 2011] [No, 2012] [Yes, 2011] [Yes, 2012] But I want it to sort as: [No, 2012] [No, 2011] [Yes, 2012] [Yes, 2011] Which means the first element in the key No/Yes should be sorted in an ascending order, whereas the timestamp should be sorted in a descending order. Is there a way to do this in a query? Or do I have to come up with some hack in my mapping function?