Sorting is a process of ordering elements in an array according to a provided order (e.g., ascending alphabetically). The output must have the same elements as the input and be sorted according to the provided order. > [!NOTE] > Sorting algorithms typically seek to achieve a **total ordering** of the elements. Mathematically, total ordering among elements in a set will have the following properties > - reflexive: $a<=a$ for all elements of $a$. > - transitive: if $a<=b$ and $b<=c$ then $a<=c$ > - anti-symmetric: if $a<=b$ and $b<=a$ then $a=b$ > - total: for any two elements $a, b$ it is the case that $a<=b$ or $b<=a$ ## sorting algorithms [[insertion sort]], [[merge sort]], [[heapsort]], [[quicksort]], TimSort, Powersort are common sorting algorithms. Each algorithm has unique benefits and drawbacks. Quicksort is one of the most commonly used. Since version 3.11, [[Python]] uses Powersort[^1]. > [!Tip]- Additional Resources > [Sort Visualizer](https://www.sortvisualizer.com/) [^1]:https://www.wild-inter.net/publications/munro-wild-2018