Sort an integer array: Difference between revisions

m
No edit summary
Line 224:
 
=={{header|Babel}}==
 
<lang babel><pre>babel> nil { zap {1 randlf 100 rem} 20 times collect ! } nest dup lsnum ! ls2lf
Use the sortval operator to sort an array of integers (val-array in Babel terminology). The following code creates a list of random values, converts it to a val-array, sorts that val-array, then converts it back to a list for display using the lsnum utility.
 
<lang babel><pre>babel> nil { zap {1 randlf 100 rem} 20 times collect ! } nest dup lsnum ! ls2lf
( 68 73 63 83 54 67 46 53 88 86 49 75 89 83 28 9 34 21 20 90 )
babel> sortval ar2ls lsnum !
( 3 12 14 16 24 29 36 38 45 46 46 55 57 57 67 72 78 80 81 90 )</pre></lang>
 
 
=={{header|BBC BASIC}}==
Anonymous user