You are viewing a single comment's thread. Return to all comments →
Check out this high-level solution:
let queue = [] let result = [] const sortedByLength = unsorted.sort((a, b) => a.length - b.length) for(let i = 0; i < sortedByLength.length; i++) { queue.push(sortedByLength[i]); if(i == sortedByLength.length-1) { result = result.concat(queue.sort()) break; } if (queue.length > 0 && sortedByLength[i+1].length > queue[0].length) { result = result.concat(queue.sort()) queue = [] } } result.forEach(v => {console.log(v)})
Seems like cookies are disabled on this browser, please enable them to open this website
Big Sorting
You are viewing a single comment's thread. Return to all comments →
Check out this high-level solution: