FastSortLibrary 1.0.0
See the version list below for details.
dotnet add package FastSortLibrary --version 1.0.0
NuGet\Install-Package FastSortLibrary -Version 1.0.0
<PackageReference Include="FastSortLibrary" Version="1.0.0" />
<PackageVersion Include="FastSortLibrary" Version="1.0.0" />
<PackageReference Include="FastSortLibrary" />
paket add FastSortLibrary --version 1.0.0
#r "nuget: FastSortLibrary, 1.0.0"
#:package FastSortLibrary@1.0.0
#addin nuget:?package=FastSortLibrary&version=1.0.0
#tool nuget:?package=FastSortLibrary&version=1.0.0
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 | Versions 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. |
-
.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.