tensort-1.1.0.0: Tunable sorting for responsive robustness and beyond
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Tensort.Subalgorithms.Magicsort

Description

This module provides the magicsort function for sorting lists

Synopsis

Documentation

magicsort :: Ord a => [a] -> [a] Source #

Takes a list and returns a sorted list.

Runs both Permutationsort and Bogosort on the input list and compares the results. If the results agree, returns the result of Permutationsort, otherwise repeats the process.

Examples

Expand
>>> magicsort ([16, 23, 4, 8, 15, 42] :: [Int])
[4,8,15,16,23,42]
>>> magicsort ([(1, 16), (5, 23), (2, 4) ,(3, 8), (0, 15), (4, 42)] :: [(Int, Int)])
[(0,15),(1,16),(2,4),(3,8),(4,42),(5,23)]