Safe Haskell | None |
---|---|
Language | Haskell2010 |
Sorting
Data.List.sort is rather inefficient when we don't care about laziness and just want to fully sort a list. An in-place sort can have much better performance. Benchmarks show that for a list of Ints, sort and sortU are 4x and 8x faster than Data.List.sort.
sort, sortBy, sortU, sortUBy use merge sort. countingSortUA uses counting sort. Both are stable sorts.
Sources:
Synopsis
- sort :: Ord e => [e] -> [e]
- sortBy :: (e -> e -> Ordering) -> [e] -> [e]
- sortU :: (Ord e, forall s. MArray (STUArray s) e (ST s), IArray UArray e) => [e] -> [e]
- sortUBy :: (forall s. MArray (STUArray s) e (ST s), IArray UArray e) => (e -> e -> Ordering) -> [e] -> [e]
- sortUABy :: (forall s. MArray (STUArray s) e (ST s), IArray UArray e) => (e -> e -> Ordering) -> UArray Int e -> UArray Int e
- countingSortUA :: (IArray UArray e, forall s. MArray (STUArray s) e (ST s)) => Int -> (e -> Int) -> UArray Int e -> UArray Int e
Documentation
sortBy :: (e -> e -> Ordering) -> [e] -> [e] Source #
Sorts a list with a comparison function. O(n log n).
sortU :: (Ord e, forall s. MArray (STUArray s) e (ST s), IArray UArray e) => [e] -> [e] Source #
Sorts a list for an element type that can be put in unboxed arrays. Faster than sort. O(n log n).
sortUBy :: (forall s. MArray (STUArray s) e (ST s), IArray UArray e) => (e -> e -> Ordering) -> [e] -> [e] Source #
Sorts a list for an element type that can be put in unboxed arrays with a comparison function. Faster than sortBy. O(n log n).