Sort numbers lexicographically: Difference between revisions

(Added AppleScript.)
Line 682:
13:1,10,11,12,13,2,3,4,5,6,7,8,9
21:1,10,11,12,13,14,15,16,17,18,19,2,20,21,3,4,5,6,7,8,9
 
=={{header|MUMPS}}==
 
This shows a few unique features of MUMPS:
 
- There is only one datatype which is implicitly coerced to string, integer, or floating-point as necessary.
- MUMPS arrays sort automatically
- The condensed version shows that there are no reserved keywords
 
<lang MUMPS>
SortLexographically(n)
new array,i,j
for i=1:1:n set array(i_" ")=""
for set j=$order(array(j)) quit:j="" write j
quit
</lang>
 
This could also be written:
 
<lang MUMPS>
SortLexographically(n) n a,i,j f i=1:1:n s a(i_" ")=""
f s j=$o(a(j)) q:j="" w j
q
</lang>
 
;Usage
 
<lang MUMPS> do SortLexographically(13)</lang>
 
{{out}}
<pre>
1 10 11 12 13 2 3 4 5 6 7 8 9
</pre>
 
=={{header|Perl}}==