Counting sort is a very time-efficient (and somewhat space-inefficient) algorithm for sorting that avoids comparisons and exploits the O(1)O(1) time insertions and lookups in an array.
The idea is simple: if you're sorting integers and you know they all fall in the range 1..1001..100, you can generate a sorted array this way:
Allocate an array numsToCounts where the indices represent numbers from our input array and the values represent how many times the index number appears. Start each value at 0.
In one pass of the input array, update numsToCounts as you go, so that at the end the values in numsToCounts are correct.
Allocate an array sortedArray where we'll store our sorted numbers.
In one in-order pass of numsToCounts put each number, the correct number of times, into sortedArray.