sdp-0.2: Simple Data Processing
Copyright(c) Andrey Mulik 2019
LicenseBSD-style
Maintainerwork.a.mulik@gmail.com
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

SDP.SortM.Insertion

Description

SDP.SortM.Insertion provides insertion sort - simple sorting algorithm.

Synopsis

Insertion Sort

insertionSort :: (LinearM m v e, BorderedM m v i, Ord e) => v -> m () Source #

insertionSortBy :: (LinearM m v e, BorderedM m v i) => Compare e -> v -> m () Source #

insertionSortBy is naive service sorting procedure, that have O(n^2) complexity in all cases.

insertionSortOn :: (LinearM m v e, BorderedM m v i, Ord o) => (e -> o) -> v -> m () Source #

insertionSortOn is a version of insertionSortBy that uses a cast function to compare elements.

unsafeInsertionSort :: LinearM m v e => Compare e -> v -> Int -> Int -> Int -> m () Source #

unsafeInsertionSort cmp es b s e is internal sorting procedure, where cmp - compare function, es - data structure, [b .. s] - sorted range, [b .. e] - sortable range.