Sorting algorithms/Bogosort: Difference between revisions

Content added Content deleted
(→‎{{header|Rust}}: Made calls a little more intuitive)
m (→‎{{header|Haskell}}: don't need another case)
Line 886: Line 886:
bogosortBy :: (a -> a -> Bool) -> [a] -> IO [a]
bogosortBy :: (a -> a -> Bool) -> [a] -> IO [a]
bogosortBy _ [] = return []
bogosortBy f xs | isSortedBy f xs = return xs
bogosortBy f xs | isSortedBy f xs = return xs
| otherwise = shuffle xs >>= bogosortBy f
| otherwise = shuffle xs >>= bogosortBy f