Skip to content

Radix Sort in C#: .NET 10, long exponent, negatives and a copy-per-call benchmark - #2372

Merged
vladimir-pecanac-main merged 3 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/71090-csharp-radix-sort
Nov 12, 2026
Merged

vladimir-pecanac-main merged 3 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/71090-csharp-radix-sort

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Moves csharp-algorithms/RadixSort to net10.0 with BenchmarkDotNet 0.15.8 and MSTest 4.5.2. RadixSort() now returns an empty array right away and uses a long exponent so an array holding int.MaxValue takes 10 passes instead of 12, CountingSort() drops the redundant zero-fill loop, and the new RadixSortWithNegatives() shifts by the smallest value with a checked subtraction. The benchmark moves into RadixSortBenchmarks, copies its input before every call so no call sorts already sorted data, and compares against Array.Sort() on random, sorted and imbalanced input. Program.cs passes args to BenchmarkRunner. Tests use (expected, actual) order and gain six cases, 10 in total.

@vladimir-pecanac-main
vladimir-pecanac-main merged commit 9ed87ad into CodeMazeBlog:main Nov 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant