You are viewing a single comment's thread. Return to all comments →
Typescript
function countSort(arr: string[][]): void { const arrHalfLen = Math.ceil(arr.length / 2); let result = []; const _arr = []; for (let i = 0; i < arr.length; i++) { if (i < arrHalfLen) { _arr.push([arr[i][0], '-']); continue; } _arr.push([arr[i][0], arr[i][1]]); } _arr.sort((a: any, b: any) => a[0] - b[0]); for (let i = 0; i < _arr.length; i++) { result.push(_arr[i][1]); } console.log(result.join(' ')); }
Seems like cookies are disabled on this browser, please enable them to open this website
The Full Counting Sort
You are viewing a single comment's thread. Return to all comments →
Typescript