clairec icon

bottom up vs top down

clairec | PRO | 09/14/16 11:31:11 PM UTC | 0 ⭐ | 574 👁️ | Never ⏰ | []
Haskell |

450 B

|

None

|

0 👍

/

0 👎

quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
    let smallerSorted = quicksort [a | a <- xs, a <= x]
        biggerSorted  = quicksort [a | a <- xs, a > x]
    in  smallerSorted ++ [x] ++ biggerSorted
 
 
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) = smallerSorted ++ [x] ++ biggerSorted
    where smallerSorted = quicksort [a | a <- xs, a <= x]
          biggerSorted  = quicksort [a | a <- xs, a > x]

Comments