The function does a linear search starting with the smallest element. If you insert in reverse order the first is always a hit so you get fewer comparisons and probably more important a very good branch prediction.
The function does a linear search starting with the smallest element. If you insert in reverse order the first is always a hit so you get fewer comparisons and probably more important a very good branch prediction.