Whenever you're ready, walk me through how you'd approach this.
Discuss the time and space complexities of common sorting algorithms such as bubble sort, insertion sort, merge sort, quicksort, and heap sort. Compare their best, average, and worst cases, and explain when you would choose one over another.