DeepSort 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DeepSort --version 0.1.0
                    
NuGet\Install-Package DeepSort -Version 0.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="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DeepSort" Version="0.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 0.1.0
                    
#r "nuget: DeepSort, 0.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@0.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=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=DeepSort&version=0.1.0
                    
Install as a Cake Tool

DeepSort

DeepSort is a .NET 10 library that implements a stable ternary merge sort: it divides data into three ranges, sorts each range, then merges the three sorted fronts back together.

The package is designed as a small algorithm library for experiments, education, and cases where you want a stable sort API with predictable O(n log n) behavior.

Install

dotnet add package DeepSort

Usage

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

Custom comparers are supported:

int[] values = [1, 4, 2, 3];

int[] descending = DeepSorter.Sort(
    values,
    Comparer<int>.Create((left, right) => right.CompareTo(left)));

Console.WriteLine(string.Join(", ", descending));
// 4, 3, 2, 1

API

  • 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)

Complexity

Case Time Extra Space
Best O(n log n) O(n)
Average O(n log n) O(n)
Worst O(n log n) O(n)

DeepSort has a shallower recursion tree than classic two-way merge sort because it splits into three ranges. The merge step still processes every element at each level, so asymptotic time remains O(n log n).

Memory Behavior

The .NET implementation avoids allocating sliced arrays during recursion. SortInPlace rents one temporary buffer from ArrayPool<T>, reuses it throughout the sort, and returns it when done.

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.0.1.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.0.1.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 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.

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 89 5/14/2026
1.0.0 95 5/14/2026
0.1.0 95 5/14/2026

Initial DeepSort .NET package with stable ternary merge sort APIs.