← Course home

Python reference · Reference

Sorting extras

Extend comparison sorting with radix methods and order-statistic selection.

ReferenceAbout 2 min

This page lists the library modules for Sorting extras. The lesson is Counting and radix sorts.

This page is the module index for sorting extras.

This legacy page is the implementation map. Use the focused pages for counting and radix sorts, order-statistic selection, binary search on a feasible answer, and inversion counting.

  • sorting/selection_and_radix.py — comparison lower bound, counting and LSD radix sorts, quickselect, binary search on the answer, inversion count.

Industry

A working engineer does not sort the whole input when only the smallest few values are required. Python's sorting howto points at heapq.nsmallest for that job: one pass that keeps only the requested number of elements. Digit keys are the other case in this lesson, counting sort and LSD radix, because a comparison lower bound does not apply to them.

Implementation and tests Optional reference

Library code 1

  • bitsandbytes.sorting.selection_and_radix

Use these references to compare the explanation with repository code and tests. A test link means it imports a lesson symbol; it does not by itself claim complete behavior coverage.