You are viewing a single comment's thread. Return to all comments →
Javascript:
function countingSort(arr) { let maxNum = Math.max(...arr) + 1; let countArray = Array(maxNum).fill(0); let resultArray = Array(); arr.forEach((num) => { countArray[num]++ }); countArray.forEach((result, index) => { for (var i = 0; i < result; i++) resultArray.push(index); }); return resultArray; }
Seems like cookies are disabled on this browser, please enable them to open this website
Counting Sort 2
You are viewing a single comment's thread. Return to all comments →
Javascript: