sorting algorithm
An algorithm that rearranges items into order, such as smallest to largest or alphabetical.
In more detail
Sorting is one of the most common operations in software, because sorted data allows binary search, range queries and easy duplicate removal. Algorithms differ in speed, extra memory, stability and behaviour on nearly sorted data. In Python you normally call sorted() or list.sort() rather than writing your own.
Related terms
- comparison sort — A sorting algorithm that learns about the order only by asking "is a smaller than b?" about pairs of items.
- stable sort — A sort that keeps items with equal keys in the same relative order they had before sorting.
- sorted() and list.sort() — Python's built-in sorts: sorted() returns a new sorted list from any iterable, and list.sort() sorts a list in place.
Taught in
- Recognising The Common Growth Rates — Algorithms & Data Structures for Working Engineers
- Comparison Sorts: Insertion, Merge And Quicksort — Algorithms & Data Structures for Working Engineers
- Counting And Radix Sort: Beating N Log N — Algorithms & Data Structures for Working Engineers
- Sorting In Real Systems: Stability, Keys And External Sort — Algorithms & Data Structures for Working Engineers
- Heaps And Priority Queues — Algorithms & Data Structures for Working Engineers
- Minimum Spanning Trees: Kruskal And Prim — Algorithms & Data Structures for Working Engineers