DeepSort 0.1.0
See the version list below for details.
dotnet add package DeepSort --version 0.1.0
NuGet\Install-Package DeepSort -Version 0.1.0
<PackageReference Include="DeepSort" Version="0.1.0" />
<PackageVersion Include="DeepSort" Version="0.1.0" />
<PackageReference Include="DeepSort" />
paket add DeepSort --version 0.1.0
#r "nuget: DeepSort, 0.1.0"
#:package DeepSort@0.1.0
#addin nuget:?package=DeepSort&version=0.1.0
#tool nuget:?package=DeepSort&version=0.1.0
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 | Versions 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. |
-
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.
Initial DeepSort .NET package with stable ternary merge sort APIs.