That’s generally called “adaptive”. A famous example of that is timsort.
Your version has issues though: insertion sort is stable, which can dangerously mislead users.
That’s generally called “adaptive”. A famous example of that is timsort.
Your version has issues though: insertion sort is stable, which can dangerously mislead users.