Files
Python/sorts
e49caf57d0 types(reverse_selection): constrain items to Comparable (#15410)
* types(reverse_selection): constrain items to Comparable

Bind reverse_selection_sort's element type to a Comparable Protocol so the
signature says "a list of items that can be compared with each other"
instead of a bare list, and keep the element type in the return.

reverse_subarray only swaps elements and never compares them, so its
TypeVar stays unbounded.

Also adds doctests for a comparable non-int type (strings, floats) and for
the failure mode: mixing non-comparable items must raise TypeError rather
than silently mis-sort. The test battery picks the sort up for the shared
cases and for the rejection check.

* updating DIRECTORY.md

---------

Co-authored-by: AuroraAeon <auroraeon@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-24 22:09:11 +02:00
..
2024-04-20 16:20:27 +02:00
2020-10-15 13:45:17 +02:00
2026-09-13 01:12:34 +02:00

Sorting Algorithms

Sorting is the process of putting data in a specific order. The way to arrange data in a specific order is specified by the sorting algorithm. The most typical orders are lexical or numerical. The significance of sorting lies in the fact that, if data is stored in a sorted manner, data searching can be highly optimised. Another use for sorting is to represent data in a more readable manner.

This section contains a lot of important algorithms that help us to use sorting algorithms in various scenarios.

References