Haskell Quicksort in JavaScript

This is a note titled "2018-04-25-haskell-quicksort-in-javascript" taken from my note Library. Return to Library.

Haskell is a really neat language! In fact, you can implement quicksort in just one line.

While this is tremendously inefficient, I thought it would be fun to create a JS version of the one-liner, should I ever need it in an interview.

const quicksort = ([h, ...arr]) => [h, ...arr].length
  ? [ ...quicksort(arr.filter(a => h >= a)), h,
      ...quicksort(arr.filter(a => h < a)) ]
  : []
Bennett Hardwick

Bennett is a Software Developer working at Clipchamp. He spends most of his day playing with React and Gatsby, and editing videos. He's not a fan of social media, but you can follow him on Github