Sort the letters of string in alphabetical order: Difference between revisions
Content added Content deleted
m (→case insensitive: use internal sort) |
|||
Line 131: | Line 131: | ||
qSort :: (Ord a) => [a] -> [a] |
qSort :: (Ord a) => [a] -> [a] |
||
qSort [] = [] |
qSort [] = [] |
||
qSort (x : xs) = before <> |
qSort (x : xs) = before <> (x:after) |
||
where |
where |
||
before = qSort [c | c <- xs, c <= x] |
before = qSort [c | c <- xs, c <= x] |
||
after = qSort [c | c <- xs, c > x] |
after = qSort [c | c <- xs, c > x] |
||
</lang> |
|||
{{Out}} |
{{Out}} |
||
<pre>" ?Iaaaaaaaabbcceeefghhhiiiiiijkllllllmnoopppsssssttt"</pre> |
<pre>" ?Iaaaaaaaabbcceeefghhhiiiiiijkllllllmnoopppsssssttt"</pre> |