According to the answer to pandas groupby sort within groups, in order to sort observations within each group one needs to do a second groupby on the results of the first groupby. Why a second groupby is needed? I would've assumed that observations are already arranged into groups after running the first groupby and all that would be needed is a way to enumerate those groups (and run apply with order).