CLN: Refactor some sorting code in Index set operations
- [ ] 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``.