FastSortLibrary 1.0.4

dotnet add package FastSortLibrary --version 1.0.4
                    
NuGet\Install-Package FastSortLibrary -Version 1.0.4
                    
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="FastSortLibrary" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FastSortLibrary" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="FastSortLibrary" />
                    
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 FastSortLibrary --version 1.0.4
                    
#r "nuget: FastSortLibrary, 1.0.4"
                    
#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 FastSortLibrary@1.0.4
                    
#: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=FastSortLibrary&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=FastSortLibrary&version=1.0.4
                    
Install as a Cake Tool

Sort faster than Array.Sort().
MiceSort()            : Single-task. A little faster. Most reliable in this library.
BothSidesNowSort()    : Multi-task. Time is less than half on intel i5 note(2 core 4 threads).

1. Usage

var sort = new SortEnvironment<T>() { // T -> element (class or value type)
   Data = {IList<T>},    // Name of T[], List<T> or other class based on IList<T>
   Compare = {Comparison<T>}, // Compare function
//    InverseOrder = true, // true = Descending
//    AlmostSorted = true, // true = Time may be shortened when data is almost sorted. Otherwise, time is late.
//    Partial = 0,        // Partial sort setting. Number larger than 0 = The specified amount of high-order elements are sorted.
   CoreCacheAmount = 256, // Data amount within each core cache. 2^N. You need to set eligible value for your sortings and CPU. 256 is initial value when omitted. (Experimental value in my PC)
// Below are only for 'BothSidesNowSort'
//    TaskAmount = 4, // Parallel task amount. Thread amount of CPU is initial value when omitted.
//    RedZone = true,     // true = Full throttle. Faster but danger. false = Under limiter. More safety.
//    MakeWayFor = false   // true = Idle cores make way for non-sort task. Time becomes slow.
};
sort.BothSidesNowSort(); // Or sort.MiceSort();

Or call Array<T>.Sort() compatible shape below. Replace * to BothSidesNowSort or MiceSort
ArraySort<T>.*(T[]);
ArraySort<T>.*(T[], IComparer<T> or Comparison<T>);
ListSort<T>.*(List<T>);
ListSort<T>.*(List<T>, IComparer<T> or Comparison<T>);

2. Character
Method  : In-place merge sort. Bottom-up approach.
Stable : Yes
Memory : Stack [log2(N/M) * 3 * int size * task amount]. (N is Data length. M is CoreCacheAmount.)
        : Instead of log2(N/M) calculation, 100 is used. [I think it sufficient safety size and present PC don't mind it.]
        : And BothSidesNowSort() multi-core control uses additional array [N/M * int size].
Time    : Comparison: O(NlogN)
        : Move: O(NlogN^2) when N is small, O(NlogN) when N is large. [My persume. Not decision]

3. Notice
- Exclusive use of challengers and human sacrifices to brand new technology
  This is good tool for confirming your PC CPU core/thread true ability.
  I can't assure this library stands up to actual purpose. You must prepare your own risk.
  Reliability : "Mice sort" > "Both sides now sort(RedZone = false)" > "Both sides now sort(RedZone = true)".
- When comparison function is time consuming, it is faster than Array.Sort().
  But when comparison function is subtraction only like common sort benchmark, slower than Array.Sort().
- This function is available to IList<T> interface implemented array structure class. (T[], List<T>)
  It can't sort LinkedList<T> because the class has no link patch function.
  (C# LinkedList<T> originally has no sort function. Array shape or LinQ(not In-place) may be standard in C# sorting.)

4. Algorithm
  Below article includes almost theory I am using but the list includes many bugs.
https://www.codeproject.com/Articles/5275988/Fastest-Sort-Algorithm

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.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.0.4 1,174 12/24/2021
1.0.3 3,878 11/26/2021
1.0.2 1,129 5/18/2021
1.0.1 1,042 5/4/2021
1.0.0 1,139 4/17/2021

Chickenless head
Turkeyless leg