Skip to content

Instantly share code, notes, and snippets.

@yoshiki
Created December 22, 2015 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoshiki/f5900d90f48249a86b78 to your computer and use it in GitHub Desktop.
Save yoshiki/f5900d90f48249a86b78 to your computer and use it in GitHub Desktop.
bswap [x] = [x]
bswap (x:y:zs)
| x < y = y : bswap (x:zs)
| otherwise = x : bswap (y:zs)
bsort :: (Ord a) => [a] -> [a]
bsort [] = []
bsort [x] = [x]
bsort xs = y : bsort ys
where
(y:ys) = reverse (bswap xs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment