Tim Sort.
Hybrid sorting algorithm derived from Merge Sort and Insertion Sort. It identifies already sorted runs and merges them efficiently.
Time complexity:
Best: O(n)
Average: O(n log n)
Worst: O(n log n)
Space complexity:
O(n)
Sorts using natural ordering.
Sorts using the provided comparator.