← Back to Sorting Algorithms

TimSort

Data Pattern:
Comparisons: 0
Swaps/Moves: 0
Array Accesses: 0
Runs Found: 0
Phase: Ready
Status: Ready

Run Stack

Empty

TimSort

Python's and Java's default sort. Finds natural runs (already sorted subsequences), extends short ones with insertion sort, then merges using a stack-based strategy.

Worst: O(n log n)
Best: O(n) (pre-sorted)
Space: O(n)
Stable: Yes

Each color = a detected run. Watch runs get extended, then merged pairwise.