FastSortLibrary 1.0.1
See the version list below for details.
dotnet add package FastSortLibrary --version 1.0.1
NuGet\Install-Package FastSortLibrary -Version 1.0.1
<PackageReference Include="FastSortLibrary" Version="1.0.1" />
<PackageVersion Include="FastSortLibrary" Version="1.0.1" />
<PackageReference Include="FastSortLibrary" />
paket add FastSortLibrary --version 1.0.1
#r "nuget: FastSortLibrary, 1.0.1"
#:package FastSortLibrary@1.0.1
#addin nuget:?package=FastSortLibrary&version=1.0.1
#tool nuget:?package=FastSortLibrary&version=1.0.1
Sort faster than Array.Sort(). [Still under debugging]
BothSidesNowSort() : Multi-task. Time is less than half on my intel i5 note(2 core 4 threads). Still, I can't solve unknown reason sort miss.
MiceSort() : Single-task. Time is a little faster. More reliable.
1. Usage
var sort = new SortEnvironment<T>() { // Change T -> class or value type of array
Data = {IList<T> Data}, // Name of T[] or List<T> or other array based structure
Compare = {Comparison<T> Compare}, // Compare function
// InverseOrder = true, // Set true if Descending
// 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. 2^N. Left value is my PC experimental one and 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.
// RedZone = true // Set true if wanting full throttle. Faster but danger. False is more safety under limiter.
};
sort.BothSidesNowSort(); // or sort.MiceSort();
Or call like one of below. Array<T>.Sort() compatible shape.
ArraySort<T>.BothSidesNowSort(T[] Data);
ArraySort<T>.BothSidesNowSort(T[] Data, IComparer<T> Comparer);
ArraySort<T>.BothSidesNowSort(T[] Data, Comparison<T> Compare);
ListSort<T>.BothSidesNowSort(List<T> Data);
ListSort<T>.BothSidesNowSort(List<T> Data, IComparer<T> Comparer);
ListSort<T>.BothSidesNowSort(List<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.]
: And additionally, 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. Not 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.
I still met unknown reason sort miss in continuous tests of "Both sides now sort(RedZone = true)".
Multi-task occasional bug is very difficult to guess the reason. Still under debugging.
In my test of present version, all faults are sort misses by some data broken. And when the sort is OK, all data is held.
And sort miss occurs always background of different application work in my test.
"Mice sort" or "Both sides now sort(RedZone = flase)" are more reliable.
But my purpose is only fastest sort. So I have not checked these long time.
- If the comparison function is only subtraction like common sort benchmark, these are slower than Array.Sort().
Only when comparison function is time consuming, these sorts are faster 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 if sorting is necessary in C#.
I think In-place sort of linked list is possible and there is the demand.)
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.
Modify 2 bugs
Add parameter List<T>