Sort three variables: Difference between revisions

Content added Content deleted
(Add BCPL)
(Added Quackery.)
Line 2,181: Line 2,181:


Three Python values:</pre>
Three Python values:</pre>

=={{header|Quackery}}==

Quackery does not have variables, instead it has ''ancillary stacks'', which, amongst their uses, can act as variables. Neither does it have operator overloading, so instead we will use <code>sortwith ></code> to sort three integers into ascending numerical order, and <code>sortwith $></code> to sort three strings into ascending QACSFOT order.

(QACSFOT is the Quackery Arbitrary Character Sequence For Ordered Text, which is <code>0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz()[]{}<>~=+-*/^\|_.,:;?!'"`%@&#$</code>. Note that, unlike the even more arbitrary ASCII/Unicode character sequence, all the punctuation marks come after all the alphabetic characters, so the result of sorting the strings will vary from the result given in the task description.)

<lang Quackery> [ stack ] is x
[ stack ] is y
[ stack ] is z
$ 'lions, tigers, and' x put
$ 'bears, oh my!' y put
$ '(from the "Wizard of OZ")' z put
x take y take z take
3 pack sortwith $> unpack
z put y put x put
say " x = " x take echo$ cr
say " y = " y take echo$ cr
say " z = " z take echo$ cr
cr
77444 x put
-12 y put
0 z put
x take y take z take
3 pack sortwith > unpack
z put y put x put
say " x = " x take echo cr
say " y = " y take echo cr
say " z = " z take echo cr</lang>

{{out}}

<pre> x = bears, oh my!
y = lions, tigers, and
z = (from the "Wizard of OZ")

x = -12
y = 0
z = 77444
</pre>



=={{header|R}}==
=={{header|R}}==