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

m
→‎{{header|Wren}}: Changed to Wren S/H
(Added Quackery.)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(One intermediate revision by one other user not shown)
Line 1,239:
=={{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 wordsphrases "alphabetical order" and "lexicographical order" to mean QACSFOT order. (''Quackery'''Q'''uackery Arbitrary'''A'''rbitrary Character'''C'''haracter Sequence'''S'''equence For'''F'''or Ordered'''O'''rdered Text'''T'''ext'').
 
The task is presented as a dialogue in the Quackery Shell: weWe take the 96 printable characters that Quackery recognises in their native (ASCII/Unicode) order, and sort them into QACSFOT order, andusing thena backword into<code>qacsort</code> nativethat orderwe have defined to do that.
 
<syntaxhighlight lang="Quackery"> [ sortwith [ qacsfot dip qacsfot > ] ] is qacsort ( $ --> $ )
 
<pre>/O> [] 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:
<pre>/O> [] 94 times [ i^ 1+ space + join ]
...
... say "Native order:" cr
... dup echo$ cr cr
... say "QACSFOT order:" cr
... sortwith [ qacsfot dip qacsfot > ]
... dup echo$ cr cr
... say "Native order:" cr
... sort
... echo$ cr
...
Native order:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
 
QACSFOT order:
0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz()[]{}<>~=+-*/^\|_.,:;?!'"`%@&#$</pre>
 
Native order:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
 
Stack empty.
 
/O> </pre>
 
=={{header|Raku}}==
Line 1,450 ⟶ 1,441:
=={{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,477

edits