| Stable? | Time | Space |
|---|---|---|
| Yes | O(n + k) | O(k) |
Explanation
Find the largest value, then make a “count” list big enough to cover that range. Go through the original list and count how many times each value appears (add 1 to the count for each value you see). Then rebuild the sorted list by walking through the count list from smallest to largest and writing each value back the number of times it was counted.
Implementation
Counting Sort