Anonymous user
Sort the letters of string in alphabetical order: Difference between revisions
Sort the letters of string in alphabetical order (view source)
Revision as of 16:36, 28 July 2021
, 2 years ago→{{header|Nim}}
Line 307:
Sorted -> .aaccddeeeeeeffghhhiiiillmmmNnnooooooooorrrstttttttuwy
</pre>
=={{header|Nim}}==
<lang Nim>import strutils, tables
func sorted(text: string; omitSpaces = false): string =
let count = text.toCountTable()
for c in '\0'..'\255':
if c == ' ' and omitSpaces: continue
result.add repeat(c, count[c])
echo sorted("The quick brown fox jumps over the lazy dog, apparently", false)
echo sorted("Now is the time for all good men to come to the aid of their country.", true)</lang>
{{out}}
<pre> ,Taaabcdeeeefghhijkllmnnoooopppqrrrsttuuvwxyyz
.Naaccddeeeeeeffghhhiiiillmmmnnooooooooorrrstttttttuwy</pre>
=={{header|Perl}}==
|