Sort an integer array: Difference between revisions

m
→‎{{header|Babel}}: Added a couple more examples
m (→‎{{header|Babel}}: Added a couple more examples)
Line 231:
babel> sortval ar2ls lsnum !
( 3 12 14 16 24 29 36 38 45 46 46 55 57 57 67 72 78 80 81 90 )</lang>
 
In Babel, lists and arrays are distinct. If you want to sort a list, use the lssort utility:
 
<lang babel>babel> ( 68 73 63 83 54 67 46 53 88 86 49 75 89 83 28 9 34 21 20 90 )
babel> {lt?} lssort ! lsnum !
( 9 20 21 28 34 46 49 53 54 63 67 68 73 75 83 83 86 88 89 90 )</lang>
 
To reverse the sort-order, use the 'gt?' predicate instead of the 'lt?' predicate:
 
<lang babel>babel> ( 68 73 63 83 54 67 46 53 88 86 49 75 89 83 28 9 34 21 20 90 ) {gt?} lssort ! lsnum !
( 90 89 88 86 83 83 75 73 68 67 63 54 53 49 46 34 28 21 20 9 )</lang>
 
=={{header|BBC BASIC}}==
Anonymous user