answersLogoWhite

0

-- empty list is already sorted

qsort [] = []

-- choose first element as pivot,

-- put all elements less than x on the left,

-- put all elements greater than x on the right,

-- recurse on both sides

qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)

User Avatar

Wiki User

16y ago

What else can I help you with?