BUG: use stable sort for group_index in groupby
Merge pull request #8148 from behzadnouri/argsort-merge-sort

BUG: use stable sort for group_index in groupby