Decorate-sort-undecorate idiom: Difference between revisions

Added XPL0 example.
(Added XPL0 example.)
Line 775:
{{out}}
<pre>["a", "is", "site", "Code", "Rosetta", "programming", "chrestomathy"]</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">
include xpllib; \for StrLen and StrSort
int A, Len, I;
char B;
[A:= [" Rosetta"," Code"," is"," a"," programming"," chrestomathy"," site"];
Len:= 7;
B:= A; \to access bytes instead of integers
for I:= 0 to Len-1 do \decorate
B(I,0):= StrLen(A(I))-1;
StrSort(A, Len);
for I:= 0 to Len-1 do
[B(I,0):= ^ ; \undecorate
Text(0, A(I));
];
]</syntaxhighlight>
{{out}}
<pre>
a is Code site Rosetta programming chrestomathy</pre>
295

edits