## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# How to do it...

1. Open src/Main.hs and write the qsort implementation. The qsort involves the following:
• Choosing an element of the list to be sorted
• Using the chosen element as a pivot, divide the input list into two parts:
• Subset of the list smaller than the pivot element
• Subset of the list greater than or equal to the pivot element
• Recursively sorting two parts in a similar way
2.  In Haskell, we can implement a method like quick sort quite easily. Ord a in the qsort declaration signifies that the elements of the list [a] can be compared for inequality, and it is possible to use the operators <, >, <=, and >=:
`        qsort :: Ord a => [a] -> [a]        qsort [] = []        qsort (x:xs) = qsort ys ++ [x] ++ qsort zs        where          ys = filter (\y -> y < x) xs zs ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required