Skip to content
StackDecode
SortingExplained

Tim Sort

Finds natural runs, extends them with insertion sort, then merges.

Time

O(n log n), O(n) if sorted

Extra space

O(n)

Use it for

Real-world data; used by Python and Java.

An animated walkthrough for this algorithm isn’t built yet. The summary above explains the idea; see the related animated algorithms below to practise the same technique.