Count Sort

00:00
EasySortingCountingArray
AmazonAdobe

Sort an array of non-negative integers using counting sort. Count occurrences, then reconstruct sorted array.

Examples

Input → [4,2,2,8,3,3,1]
Output → [1,2,2,3,3,4,8]
Input → [1,4,1,2,7,5,2]
Output → [1,1,2,2,4,5,7]
Input → [0]
Output → [0]