FastSortLibrary 1.0.3
See the version list below for details.
dotnet add package FastSortLibrary --version 1.0.3
NuGet\Install-Package FastSortLibrary -Version 1.0.3
<PackageReference Include="FastSortLibrary" Version="1.0.3" />
<PackageVersion Include="FastSortLibrary" Version="1.0.3" />
<PackageReference Include="FastSortLibrary" />
paket add FastSortLibrary --version 1.0.3
#r "nuget: FastSortLibrary, 1.0.3"
#:package FastSortLibrary@1.0.3
#addin nuget:?package=FastSortLibrary&version=1.0.3
#tool nuget:?package=FastSortLibrary&version=1.0.3
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 my 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 = Data is almost sorted (Time may be shortened in the case. Otherwise, time is longer.)
// 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. 256 is initial value when omitted. (Experimental value in my PC)
// Below are only for 'BothSidesNowSort'
// TaskAmount = 4, // Parallel task amount. Environment.ProcessorCount (Thread amount) is initial value when omitted.
// RedZone = true, // true = Full throttle. Faster but danger. false = Under limiter. More safety.
WaitCount = 1000000, // Wait count for CPU memory cache adjustment. 1000000 is chicken initial value when omitted, that passed test in my PC.
// You must set eligible value for your PC CPU. Set 0 if you aspire speed than no accident.
// MakeWayFor = false // true = Idle cores make way for not-sort task. Time becomes slow.
};
sort.BothSidesNowSort(); // 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 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, faster than Array.Sort().
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 | 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.
Data change bug maybe probably fixed or I gave up settlement.
Throwing away logical consideration of memory cache control derived from all documents I read,
I stuck spam talismans of incantation on every interval and in every loop.
These have taken effect in my test.