Skip to content

Instantly share code, notes, and snippets.

@kaveet
Created November 21, 2016 15:03
Show Gist options
  • Save kaveet/f3601316ce415e16fd4d927a3522cd0c to your computer and use it in GitHub Desktop.
Save kaveet/f3601316ce415e16fd4d927a3522cd0c to your computer and use it in GitHub Desktop.
Haskell Selection Sort
module SelectionSort where
selSort :: (Ord a) => [a] -> [a]
selSort [] = []
selSort xs = let x = maximum xs in selSort (remove x xs) ++ [x]
where remove _ [] = []
remove a (x:xs)
| x == a = xs
| otherwise = x : remove a xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment