Quick Sort in C#: A Generic, Span-Based Implementation
A quick sort implementation in modern C# that works on any comparable type, avoids the classic worst case on sorted input, and keeps stack depth under control.
A quick sort implementation in modern C# that works on any comparable type, avoids the classic worst case on sorted input, and keeps stack depth under control.
A stable counting sort in modern C# that handles negative numbers, explains the O(n + k) trade-off and guards against ranges too large to count.
Bubble sort in modern C# for any comparable type, with the early-exit check that makes sorted input O(n), plus an honest look at when to use it.
Insertion sort in modern C# for any comparable type, why it beats quick sort on small or nearly sorted arrays, and where .NET itself uses it.
Selection sort in modern C# for any comparable type, a fix for a common mistake in older versions, and the one case where it beats other simple sorts.