REF: move safe_sort to algos to avoid private/circular dependencies
safe_sort uses private functions from core.algorithms and is runtime-imported into core.algorithms.  It also doesn't use _anything_ else defined in core.sorting.  This move cleans up the dependency structure, in particular is a step towards getting #29133 working.