How to sort a hit array by instance index?

You can use min / max of array + While loop.

The first loop creates a random array. While loop keeps picking min integer for as long as there anything in the unsorted left, adds it to a sorted array and removes it from unsorted. This prints the sorted from min to max value.

308338-annotation-2020-07-28-165124.jpg