Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library
← Back to context

Comment by vunderba

18 days 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

0 comments

vunderba

Reply

No comments yet

Contribute on Hacker News ↗

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities