 Practical general sorting algorithms are almost always based on an algorithm with average time complexity (and generally worst-case complexity) O("n" log "n"), of which the most common are heap sort, merge sort, and quicksort.Each has advantages and drawbacks, with the most significant being that simple implementation of merge sort uses O("n") additional space, and simple implementation of quicksort has O("n"2) worst-case complexity.These problems can be solved or ameliorated at the cost of a more complex algorithm.