2 ms·
The collapse sort "algorithm". A = [2, 7, 1, 8, 28, 18] sort = A => A.reduce((B, x) => (B[x] = x, B), []).filter(x => x) Nothing says efficiency like a so
by vunderba 9mo ago
The collapse sort "algorithm".
A = [2, 7, 1, 8, 28, 18]
sort = A => A.reduce((B, x) => (B[x] = x, B), []).filter(x => x)
Nothing says efficiency like a sorting algorithm where Big O is more influenced by the largest element's value rather than the number of elements in the array. /s