Sort the letters of string in alphabetical order: Difference between revisions

→‎{{header|Haskell}}: Slightly rephrased the question in Haskell
(→‎{{header|Haskell}}: Added a question in Haskell)
(→‎{{header|Haskell}}: Slightly rephrased the question in Haskell)
Line 117:
sort
"Is this misspelling of alphabetical as alphabitical a joke ?"</lang>
{{Out}}
<pre>" ?Iaaaaaaaabbcceeefghhhiiiiiijkllllllmnoopppsssssttt"</pre>
 
Or, sketching a rough re-phrase of the question:
 
<lang haskell>main :: IO ()
main =
print $
qSort
"Is this misspelling of alphabetical as alphabitical a joke ?"
 
 
qSort :: (Ord a) => [a] -> [a]
qSort [] = []
qSort (x : xs) = before <> [x] <> after
where
before = qSort [c | c <- xs, c <= x]
after = qSort [c | c <- xs, c > x]</lang>
{{Out}}
<pre>" ?Iaaaaaaaabbcceeefghhhiiiiiijkllllllmnoopppsssssttt"</pre>
9,659

edits