module

Nucleoc::ParSort

Class methods

sort(array : Array(T), is_less : T, T -> Bool = ->(a : T, b : T) do a < b end, canceled : CancelFlag | Nil = nil) : Bool forall T

Sorts array in parallel using a hybrid algorithm.

The algorithm is a parallel quicksort that switches to insertion sort for small partitions and uses a work-stealing approach for load balancing.

  • is_less should return true if its first argument is strictly less than its second.
  • canceled is an atomic flag that can be set to true to cancel the sort. If canceled, a CancellationError is raised in worker fibers.

Returns true if the sort was canceled, false otherwise.

Source

Nested types