DeepSort 1.1.0

dotnet add package DeepSort --version 1.1.0
                    
NuGet\Install-Package DeepSort -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DeepSort" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DeepSort" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="DeepSort" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DeepSort --version 1.1.0
                    
#r "nuget: DeepSort, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DeepSort@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DeepSort&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=DeepSort&version=1.1.0
                    
Install as a Cake Tool

DeepSort

The definitive .NET sorting library — 12 algorithms, adaptive selection, parallel sorting, and full complexity metadata.

DeepSort is the new era of sorting: pick any algorithm by name, let the adaptive engine choose for you, or unleash parallel merge sort for massive datasets. Every algorithm is production-grade, thoroughly tested, and ships with detailed complexity info.

Install

dotnet add package DeepSort

Quick Start

using DeepSort;

int[] numbers = [73, 12, 45, 8, 91, 33, 67, 5, 28];
int[] sorted = DeepSorter.Sort(numbers);

Console.WriteLine(string.Join(", ", sorted));
// 5, 8, 12, 28, 33, 45, 67, 73, 91

Sort returns a new array and leaves the input unchanged.

string[] words = ["banana", "apple", "cherry", "apple"];

DeepSorter.SortInPlace(words);

Console.WriteLine(string.Join(", ", words));
// apple, apple, banana, cherry

Choose Your Algorithm

// Use any of the 12 built-in algorithms
int[] values = [42, 17, 93, 5, 67, 31];

var sorted = DeepSorter.Sort(values, SortAlgorithm.TimSort);
var quick  = DeepSorter.Sort(values, SortAlgorithm.DualPivotQuickSort);
var heap   = DeepSorter.Sort(values, SortAlgorithm.HeapSort);

Let DeepSort Decide

The adaptive engine analyzes your data and picks the best algorithm:

var sorted = DeepSorter.Sort(values, SortAlgorithm.Adaptive);

It considers array size, sortedness ratio, and data type to select the optimal strategy.

Custom Comparers

int[] descending = DeepSorter.Sort(
    values,
    SortAlgorithm.DualPivotQuickSort,
    Comparer<int>.Create((a, b) => b.CompareTo(a)));

Parallel Sorting

For large datasets, parallel merge sort distributes work across all available cores:

var largeArray = Enumerable.Range(0, 1_000_000).Select(_ => Random.Shared.Next()).ToArray();

// Uses all CPU cores for maximum throughput
var sorted = DeepSorter.ParallelSort(largeArray);

// In-place variant
DeepSorter.ParallelSortInPlace(largeArray);

Algorithm Complexity Info

Query complexity metadata at runtime:

var info = DeepSorter.GetComplexity(SortAlgorithm.TimSort);

Console.WriteLine($"Best:    {info.BestTime}");    // O(n)
Console.WriteLine($"Average: {info.AverageTime}");  // O(n log n)
Console.WriteLine($"Worst:   {info.WorstTime}");    // O(n log n)
Console.WriteLine($"Space:   {info.Space}");         // O(n)
Console.WriteLine($"Stable:  {info.IsStable}");      // True

All 12 Algorithms

Algorithm Time (Best) Time (Avg) Time (Worst) Space Stable Best For
TernaryMergeSort O(n log n) O(n log n) O(n log n) O(n) ✅ Default, shallow recursion
DualPivotQuickSort O(n log n) O(n log n) O(n²) O(log n) ❌ Large random datasets
HeapSort O(n log n) O(n log n) O(n log n) O(1) ❌ Guaranteed perf, low memory
InsertionSort O(n) O(n²) O(n²) O(1) ✅ Small / nearly-sorted data
ShellSort O(n log n) O(n^1.25) O(n^1.5) O(1) ❌ Medium datasets
RadixSort O(nk) O(nk) O(nk) O(n+k) ✅ Integer / fixed-width data
CountingSort O(n+k) O(n+k) O(n+k) O(k) ✅ Small-range integers
TimSort O(n) O(n log n) O(n log n) O(n) ✅ Real-world data with runs
IntroSort O(n log n) O(n log n) O(n log n) O(log n) ❌ Worst-case protection
BubbleSort O(n) O(n²) O(n²) O(1) ✅ Educational
SelectionSort O(n²) O(n²) O(n²) O(1) ❌ Educational, minimal swaps
CocktailShakerSort O(n) O(n²) O(n²) O(1) ✅ Nearly-sorted (bidirectional)

Full API Reference

Default Sort (Ternary Merge Sort)

  • DeepSorter.Sort<T>(IEnumerable<T> values)
  • DeepSorter.Sort<T>(IEnumerable<T> values, IComparer<T>? comparer)
  • DeepSorter.Sort<T>(ReadOnlySpan<T> values)
  • DeepSorter.Sort<T>(ReadOnlySpan<T> values, IComparer<T>? comparer)
  • DeepSorter.SortInPlace<T>(T[] values)
  • DeepSorter.SortInPlace<T>(T[] values, IComparer<T>? comparer)
  • DeepSorter.SortInPlace<T>(Span<T> values)
  • DeepSorter.SortInPlace<T>(Span<T> values, IComparer<T>? comparer)

Algorithm Selection

  • DeepSorter.Sort<T>(IEnumerable<T> values, SortAlgorithm algorithm)
  • DeepSorter.Sort<T>(IEnumerable<T> values, SortAlgorithm algorithm, IComparer<T>? comparer)
  • DeepSorter.SortInPlace<T>(T[] values, SortAlgorithm algorithm)
  • DeepSorter.SortInPlace<T>(T[] values, SortAlgorithm algorithm, IComparer<T>? comparer)
  • DeepSorter.SortInPlace<T>(Span<T> values, SortAlgorithm algorithm)
  • DeepSorter.SortInPlace<T>(Span<T> values, SortAlgorithm algorithm, IComparer<T>? comparer)

Parallel Sort

  • DeepSorter.ParallelSort<T>(IEnumerable<T> values)
  • DeepSorter.ParallelSort<T>(IEnumerable<T> values, IComparer<T>? comparer)
  • DeepSorter.ParallelSortInPlace<T>(T[] values)
  • DeepSorter.ParallelSortInPlace<T>(T[] values, IComparer<T>? comparer)

Metadata

  • DeepSorter.GetComplexity(SortAlgorithm algorithm) → SortComplexity

Memory Behavior

All merge-based algorithms rent buffers from ArrayPool<T> and return them when done — no garbage left behind. In-place algorithms (heap, shell, insertion, bubble, selection, cocktail) use O(1) extra memory.

Build From Source

dotnet restore
dotnet test
dotnet pack src/DeepSort/DeepSort.csproj -c Release

The package file will be created under:

src/DeepSort/bin/Release/DeepSort.1.0.0.nupkg

Publish To NuGet

Create an API key at https://www.nuget.org/account/apikeys, then run:

dotnet nuget push src/DeepSort/bin/Release/DeepSort.1.0.0.nupkg `
  --api-key YOUR_NUGET_API_KEY `
  --source https://api.nuget.org/v3/index.json

If the DeepSort package ID is unavailable, change <PackageId> in src/DeepSort/DeepSort.csproj to a unique name such as Ayush.DeepSort, rebuild, and publish that package instead.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 143 5/14/2026
1.0.0 124 5/14/2026
0.1.0 120 5/14/2026

v1.0.0 — The New Era of Sorting
- 12 sorting algorithms: TernaryMergeSort, DualPivotQuickSort, HeapSort, InsertionSort, ShellSort, RadixSort, CountingSort, TimSort, IntroSort, BubbleSort, SelectionSort, CocktailShakerSort
- Adaptive algorithm selection that analyzes data characteristics
- Parallel merge sort for large datasets
- Algorithm complexity metadata API
- 100% backward-compatible with v0.1 API