FastSortLibrary 1.0.0

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

Sort faster than Array.Sort(). [Not finished]

BothSidesNowSort() : Multitask. Time is less than half on my intel i5 note(2 core 4 threads).
MiceSort() : Single-task. Time is a little faster.

(Time sample: same random number array)
Array.Sort(): sorted 1000000elements in 13538msec.
LinQ OrderBy: sorted 1000000elements in 14598msec.
Mice Sort: sorted 1000000elements in 13070msec.
Both Sides Now Sort: sorted 1000000elements in 5721msec.

1. Usage

var sort = new SortEnvironment<T>() { // Change T -> class or value type of array
Data = {T[] Data}, // Sort array name
Compare = {Comparison<T> Compare}, // Compare function
// InverseOrder = true, // Set true if Decending
// AlmostSorted = true, // Set true if the array is almost sorted (Time may be shortened. Normally time becomes longer.)
// CoreCacheAmount = 256, // Data amount that can be stored each core cache. This is my PC experimental value. It is used if this setting is omitted.
// Below setting is only for 'BothSidesNowSort'
// TaskAmount = 4 // Parallel task amount. Environment.ProcessorCount (Thread amount) is used if this setting is omitted.
};
sort.BothSidesNowSort(); // or sort.MiceSort();

Or call like one of below. Array<T>.Sort() compatible parameter.
ArraySort<T>.BothSidesNowSort(T[] Data);
ArraySort<T>.BothSidesNowSort(T[] Data, IComparer<T> Comparer);
ArraySort<T>.BothSidesNowSort(T[] Data, Comparison<T> Compare);

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

3. Notice
- For chalenger and human sacrifice to brand new technology only
  This is good tool for confirming your PC CPU core/thread true ability.
  In my continuous test about 3 days, present version always worked right. (No sort miss. No lock up. No break down.)
  But I have not finished this program theoretical verification. (Timing problem is very difficult.)
  You may meet some kind trouble. I wish not to so.
- If the comparison function is only subtraction like common sort benchmark, these are slower than Array.Sort().
  Only when comparison function is time consuming, this sort is faster than Array.Sort().
- List<T>, IEnumerable<T> don't provide necessary function for that user can attach sort process.
  So I give up though I am sure that parallel process may make these sorting faster.
- I don't use ManagementObjectCollection. It is very slow and prevent benchmark and I have not found the relation between cache size and cachable data amount.
  By that, this is large range adaptable .NET Standard library.
- When it becomes C-language shape, it will be the fastest sort function of all and after. That will be after deciding C# shape.

4. Algorithm
  Below article includes almost theory I using but the list in it includes many bugs. (A little previous version)
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