quick sort, funcitonal and imperative