BUG: Bug in DataFrameGroupby.transform when transforming with a passed non-sorted key (GH8046)

closes #8046