Decorate-sort-undecorate idiom: Difference between revisions

Content added Content deleted
m (→‎{{header|Haskell}}: Added version with hidden decoration and undecoration)
Line 253: Line 253:
("chrestomathy",12)</pre>
("chrestomathy",12)</pre>


and equivalently:

<syntaxhighlight lang="haskell">import Data.List (sortOn)

main :: IO ()
main =
mapM_ print $
sortOn
length
[ "Rosetta",
"code",
"is",
"a",
"programming",
"chrestomathy",
"site"
]</syntaxhighlight>
{{Out}}
<pre>"a"
"is"
"code"
"site"
"Rosetta"
"programming"
"chrestomathy"</pre>


=={{header|JavaScript}}==
=={{header|JavaScript}}==