Haskell排列排序

示例

也称为bogosort。

importData.List(permutations)

sorted :: Ord a => [a] -> Bool
sorted (x:y:xs) = x <= y && sorted (y:xs)
sorted _        = True

psort :: Ord a => [a] -> [a]
psort = head . filter sorted . permutations

效率极低(在当今的计算机上)。