CLN: Refactor some sorting code in Index set operations
State: closed

- [ ] Related to #24521
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`

This is a pre-cursor to #24521 and cleans up some of the sorting code in set operations on ``Index``.

Labels:
name: Reshaping
description: Concat, Merge/Join, Stack/Unstack, Explode
name: Compat
description: pandas objects compatability with Numpy or Python functions

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24533?src=pr&el=h1) Report
> Merging [#24533](https://codecov.io/gh/pandas-dev/pandas/pull/24533?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/091cfbb053c8522acd4f851f6a93626751e77dbb?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master   #24533   +/-   ##
=======================================
  Coverage   31.88%   31.88%           
=======================================
  Files         166      166           
  Lines       52427    52427           
=======================================
  Hits        16714    16714           
  Misses      35713    35713
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `30.28% <0%> (ø)` | :arrow_up: |
| #single | `31.88% <0%> (ø)` | :arrow_up: |


------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24533?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/24533?src=pr&el=footer). Last update [091cfbb...f8bfb91](https://codecov.io/gh/pandas-dev/pandas/pull/24533?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24533?src=pr&el=h1) Report
> Merging [#24533](https://codecov.io/gh/pandas-dev/pandas/pull/24533?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/091cfbb053c8522acd4f851f6a93626751e77dbb?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master   #24533   +/-   ##
=======================================
  Coverage   31.88%   31.88%           
=======================================
  Files         166      166           
  Lines       52427    52427           
=======================================
  Hits        16714    16714           
  Misses      35713    35713
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `30.28% <0%> (ø)` | :arrow_up: |
| #single | `31.88% <0%> (ø)` | :arrow_up: |


------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24533?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/24533?src=pr&el=footer). Last update [091cfbb...f8bfb91](https://codecov.io/gh/pandas-dev/pandas/pull/24533?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

thanks @reidy-p