hgeometry-combinatorial
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellSafe-Inferred
LanguageGHC2021

HGeometry.Foldable.Sort

Description

Sorting foldable collections by using fast sorting functions from vector-algorithms.

Synopsis

Documentation

sortBy :: forall vector f a. (Foldable f, Vector vector a) => (a -> a -> Ordering) -> f a -> vector a Source #

Sort a collection using the given comparator using intro-sort (essentially quicksort).

\(O(T n\log n)\), where \(T\) is the time to do a comparison.

sort :: forall vector f a. (Foldable f, Vector vector a, Ord a) => f a -> vector a Source #

Sort the given collection using intro sort.

\(O(n\log n)\)

sortOnCheap :: forall vector f a b. (Foldable f, Vector vector a, Ord b) => (a -> b) -> f a -> vector a Source #

Sort the collection using the given "cheap" function; i.e. the function f is called at every comparison

\(O(Tn\log n)\), where \(T\) is the time required to evaluate the function