bubblesort’ :: (Ord a) => [a] -> ([a], Bool)

bubblesort’ [] = ([], False)

bubblesort’ [x] = ([x], False)

bubblesort’ (x:y:xs)

| x [a] -> [a]

bubblesort xs @ _

| swapped = bubblesort tc

| otherwise = tc

where (tc, swapped) = bubblesort’ xs ]]>

Best regards.

]]>sorted :: (Ord a) => [a] -> Bool

sorted [] = True

sorted (_:[]) = True

sorted lst @ (x:y:xs) = x [a] -> [a]

bubbleSort [] = []

bubbleSort a @ (_:[]) = a

bubbleSort lst = until(sorted)(\(x:y:xs) -> (min x y) : bubbleSort((max x y) : xs)) lst