BUG: Maintain column order with groupby.nth
- [ ] closes #20760
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Hello @reidy-p! Thanks for updating the PR.

 - There are no PEP8 issues in the file [`pandas/core/groupby/groupby.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/core/groupby/groupby.py) !

 - There are no PEP8 issues in the file [`pandas/core/indexes/base.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/core/indexes/base.py) !

 - There are no PEP8 issues in the file [`pandas/core/indexes/interval.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/core/indexes/interval.py) !

 - There are no PEP8 issues in the file [`pandas/core/indexes/multi.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/core/indexes/multi.py) !

 - There are no PEP8 issues in the file [`pandas/tests/groupby/test_nth.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/tests/groupby/test_nth.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/common.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/tests/indexes/common.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/datetimes/test_setops.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/tests/indexes/datetimes/test_setops.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/interval/test_interval.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/tests/indexes/interval/test_interval.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/multi/test_set_ops.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/tests/indexes/multi/test_set_ops.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/period/test_period.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/tests/indexes/period/test_period.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/period/test_setops.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/tests/indexes/period/test_setops.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/test_base.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/tests/indexes/test_base.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/timedeltas/test_timedelta.py`](https://github.com/reidy-p/pandas/blob/f7446b5a763cc534e34aca06c00e07e5e7f4ee9d/pandas/tests/indexes/timedeltas/test_timedelta.py) !



##### Comment last updated on October 20, 2018 at 22:24 Hours UTC # [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22811?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@960a73f`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `81.81%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/22811/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/22811?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master   #22811   +/-   ##
=========================================
  Coverage          ?    92.2%           
=========================================
  Files             ?      169           
  Lines             ?    50927           
  Branches          ?        0           
=========================================
  Hits              ?    46955           
  Misses            ?     3972           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.62% <81.81%> (?)` | |
| #single | `42.3% <45.45%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22811?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/multi.py](https://codecov.io/gh/pandas-dev/pandas/pull/22811/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9tdWx0aS5weQ==) | `95.46% <100%> (ø)` | |
| [pandas/core/groupby/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/22811/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9ncm91cGJ5LnB5) | `96.47% <100%> (ø)` | |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/22811/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.55% <66.66%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22811?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22811?src=pr&el=footer). Last update [960a73f...13a23f7](https://codecov.io/gh/pandas-dev/pandas/pull/22811?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 the other issue is #17378 #20809 and #17878 are also related. I'm working on trying to expand the pull request to the other set ops but it will take a few more days at least. just wanted to make you aware of the other issues

not super necessary to actually do it in this PR unless it’s straightforwars Mostly cross referencing for myself. #21603 should become a lot easier when this is completed; `first` and `last` could not be written strictly in terms of `nth` due to the column ordering. lgtm. can you rebase, ping on green. @jreback I've rebased now but do you want me to add ``sort=True`` to the other set operations in this PR too (or just the subclasses of Index) as you suggested above? I've started it but it needs a bit more work. I can put it in a new PR if it's easier.

@mroeschke I had the exact same thought when I was working on a PR for ``first`` and ``last`` which is why I opened this PR first! > PR too (or just the subclasses of Index) as you suggested above? I've started it but it needs a bit more work. I can put it in a new PR if it's easier.

yes new PR after this is merged.
 I have made some updates but I just realised that I need to add the new sort parameter to the tests for the subclasses of Index can you rebase and fixup rebased. though will look again. thanks @reidy-p nice job!