8. [10%] Please write the quick-sort code to sort n items and explain its average and worst-case time complexity.