BUG: groupby apply raises ValueError when groupby axis has duplicates and applied identity function
This is a more of a patch than a complete solution to this groupby apply paradigm. 
When there are duplicates in the groupby axis, we restore the axis to its original order, but not guaranteeing that the order of the data with the same axis values is restored.

- [x] closes #30667
- [x] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry
