BUG: Fixes #2799

Use `np.sort` instead of `sorted` when the input is a list and no indices
are requested. Fixes #2799.