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
License
—
Deps
0
Install Size
—
Vulns
✓ 0
Published
Dec 24, 2021
$ dotnet add package FastSortLibraryNo README available.