C# – How to sort by multiple fields

Use OrderBy() and ThenBy() when you want to sort by multiple fields, like this: Note: These are Linq extension methods, so make sure to add a reference to System.Linq. Ascending vs Descending order By default, OrderBy() and ThenBy() sort in ascending order. If you want to sort by descending order, use the Descending version of … Read more C# – How to sort by multiple fields

Multithreaded quicksort in C#

One day I decided to challenge myself by trying to implement multithreaded quicksort. I wanted to see how it would compare to the built-in sort function – Array.Sort(). I came up with two algorithms that were 2-4x faster than Array.Sort(): Top-down: divide-fork-sort-merge Bottom-up: quicksort with fork-on-recursion After continuing to tinker, in attempts to further optimize, … Read more Multithreaded quicksort in C#