Coding & data structures · Sorting and selection — order, and the parts of it you actually need

Sorting: the invariant you are buying

Nobody will ask you to implement quicksort, and everybody will judge the comparator you write, the stability you assume, and whether you noticed that the O(n log n) you just added is now the dominant term — so this lesson treats sorting as a purchase: what invariant does the order give you, what does it cost, and when is the price wrong.

26 min read Full lesson in the app Patterns: comparator, stable sort, counting sort, radix sort, sort as preprocessing

What you'll be able to do

Before this: complexity-honestly, two-pointers

The rest of this lesson is in the app

Nobody will ask you to implement quicksort, and everybody will judge the comparator you write, the stability you assume, and whether you noticed that the O(n log n) you just added is now the dominant term — so this lesson treats sorting as a purchase: what invariant does the order give you, what does it cost, and when is the price wrong. This walkthrough runs about 26 minutes, with runnable code you can edit and re-run as you read.

Continue in ChannelPulse

The first module of every track is free to read on the web — see what's open in Coding & data structures.