-- Haskell "quicksort"
-- Based on 
-- http://www.haskell.org/haskellwiki/Introduction#Quicksort_in_Haskell
-- This is *not* an efficient implementation -- some would say it's
-- not even really quicksort -- but neatly presents the essential
-- strategy of quicksort:

-- qsort1, using filter

qsort1 :: (Ord t) => [t] -> [t]
qsort1 []     = []
qsort1 (x:xs) = qsort1 (filter (< x) xs) ++ [x] ++ qsort1 (filter (>= x) xs)

-- What is meant by Ord t?
-- What is filter? ...
-- What is (> x)?  ...
--         (>= x)? ...

-- qsort 2, same idea, using list comprehensions

qsort2 :: (Ord t) => [t] -> [t]
qsort2 [] = []
qsort2 (x:xs) = qsort2 [y | y <- xs, y < x] ++
                [x] ++
                qsort2 [y | y <- xs, y >= x]
