# Timsort

## Hybrid sorting algorithm based on insertion sort and merge sort / From Wikipedia, the free encyclopedia

#### Dear Wikiwand AI, let's keep it short by simply answering these key questions:

Can you list the top facts and stats about Timsort?

Summarize this article for a 10 year old

**Timsort** is a hybrid, stable sorting algorithm, derived from merge sort and insertion sort, designed to perform well on many kinds of real-world data. It was implemented by Tim Peters in 2002 for use in the Python programming language. The algorithm finds subsequences of the data that are already ordered (runs) and uses them to sort the remainder more efficiently. This is done by merging runs until certain criteria are fulfilled. Timsort was Python's standard sorting algorithm from version 2.3 to version 3.10,^{[5]} and is used to sort arrays of non-primitive type in Java SE 7,^{[6]} on the Android platform,^{[7]} in GNU Octave,^{[8]} on V8,^{[9]} Swift,^{[10]} and inspired the sorting algorithm used in Rust.^{[11]}

**Quick Facts**Class, Data structure ...

Class | Sorting algorithm |
---|---|

Data structure | Array |

Worst-case performance | $O(n\log n)$^{[1]}^{[2]} |

Best-case performance | $O(n)$^{[3]} |

Average performance | $O(n\log n)$ |

Worst-case space complexity | $O(n)$ |

Optimal | No^{[4]} |

It uses techniques from Peter McIlroy's 1993 paper "Optimistic Sorting and Information Theoretic Complexity".^{[12]}