FastSortLibrary 1.0.4
dotnet add package FastSortLibrary --version 1.0.4
NuGet\Install-Package FastSortLibrary -Version 1.0.4
<PackageReference Include="FastSortLibrary" Version="1.0.4" />
<PackageVersion Include="FastSortLibrary" Version="1.0.4" />
<PackageReference Include="FastSortLibrary" />
paket add FastSortLibrary --version 1.0.4
#r "nuget: FastSortLibrary, 1.0.4"
#:package FastSortLibrary@1.0.4
#addin nuget:?package=FastSortLibrary&version=1.0.4
#tool nuget:?package=FastSortLibrary&version=1.0.4
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 | 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.
Chickenless head
Turkeyless leg