Question : sort list haskell
Answered by : fine-flamingo-uw1y5hp8vw22
quicksort :: Ord a => [a] -> [a]
quicksort [] = []
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater) where lesser = filter (< p) xs greater = filter (>= p) xs
Source : https://wiki.haskell.org/Introduction#Quicksort_in_Haskell | Last Update : Sun, 05 Jul 20
Question : sortOn haskell
Answered by : afonso-silva
sortOn :: Ord b => (a -> b) -> [a] -> [a]
>>> sortOn fst [(2, "world"), (4, "!"), (1, "Hello")]
[(1,"Hello"),(2,"world"),(4,"!")]
Source : https://hackage.haskell.org/package/base-4.16.0.0/docs/Data-List.html#v:sortOn | Last Update : Wed, 19 Jan 22