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

m
→‎{{header|Wren}}: Changed to Wren S/H
(K)
m (→‎{{header|Wren}}: Changed to Wren S/H)
(3 intermediate revisions by 2 users not shown)
Line 1,236:
{{Out}}
<pre>" ?Iaaaaaaaabbcceeefghhhiiiiiijkllllllmnoopppsssssttt"</pre>
 
=={{header|Quackery}}==
 
With regard to the [[Talk:Sort the letters of string in alphabetical order|discussion]] regarding the nature of the task, I am construing the phrases "alphabetical order" and "lexicographical order" to mean QACSFOT order. ('''''Q'''uackery '''A'''rbitrary '''C'''haracter '''S'''equence '''F'''or '''O'''rdered '''T'''ext'')
 
We take the 96 printable characters that Quackery recognises in their native (ASCII/Unicode) order, and sort them into QACSFOT order using a word <code>qacsort</code> that we have defined to do that.
 
<syntaxhighlight lang="Quackery"> [ sortwith [ qacsfot dip qacsfot > ] ] is qacsort ( $ --> $ )
 
[] 94 times [ i^ 1+ space + join ]
 
say "Native order:" cr
dup echo$ cr cr
say "QACSFOT order:" cr
qacsort echo$</syntaxhighlight>
 
{{out}}
 
<pre>Native order:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
 
QACSFOT order:
0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz()[]{}<>~=+-*/^\|_.,:;?!'"`%@&#$</pre>
 
=={{header|Raku}}==
Line 1,367 ⟶ 1,390:
Output: aaaeeefgggggiilmmnnnooprrrrruv
done...
</pre>
 
=={{header|RPL}}==
{{works with|HP|48G}}
≪ { }
1 3 PICK SIZE '''FOR''' j
OVER j DUP SUB + '''NEXT'''
SWAP DROP
SORT ∑LIST
≫ '<span style="color:blue">STRORT</span>' STO
 
"The quick brown fox jumps over the lazy dog, apparently" <span style="color:blue">STRORT</span>
{{out}}
<pre>
1: " ,Taaabcdeeeefghhijkllmnnoooopppqrrrsttuuvwxyyz"
</pre>
 
Line 1,400 ⟶ 1,438:
,Taaabcdeeeefghhijkllmnnoooopppqrrrsttuuvwxyyz
</pre>
 
=={{header|Wren}}==
Well, we'll write a function for a bubble sort which we don't have in Wren-sort because it's normally much slower than the other methods. However, it's fast enough here.
<syntaxhighlight lang="ecmascriptwren">var bubbleSort = Fn.new { |s, trim| // allow optional removal of whitespace
var chars = s.toList
var n = chars.count
9,485

edits