Sort the letters of string in alphabetical order: Difference between revisions
Content added Content deleted
m (added whitespace.) |
m (→{{header|Haskell}}: Used partition for the rough and ready sort) |
||
Line 150: | Line 150: | ||
Or, sketching a rough re-phrase of the question: |
Or, sketching a rough re-phrase of the question: |
||
<lang haskell> |
<lang haskell>import Data.List (partition) |
||
main :: IO () |
|||
main = |
main = |
||
print $ |
print $ |
||
Line 158: | Line 160: | ||
qSort :: (Ord a) => [a] -> [a] |
qSort :: (Ord a) => [a] -> [a] |
||
qSort [] = [] |
qSort [] = [] |
||
qSort (x : xs) = |
qSort (x : xs) = qSort below <> (x : qSort above) |
||
where |
where |
||
(below, above) = partition (<= x) xs</lang> |
|||
{{Out}} |
{{Out}} |
||
<pre>" ?Iaaaaaaaabbcceeefghhhiiiiiijkllllllmnoopppsssssttt"</pre> |
<pre>" ?Iaaaaaaaabbcceeefghhhiiiiiijkllllllmnoopppsssssttt"</pre> |