Anonymous user
Higher-order functions: Difference between revisions
m
→{{header|JavaScript}}: Removed semi-colons from last two examples' anonymous functions
m (→{{header|JavaScript}}: Removed semi-colons from last two examples' anonymous functions) |
|||
Line 512:
// sort the array from smallest to largest
>>> array.sort(function (a, b) { return a > b
[2, 4, 5, 13, 18, 24, 34, 97]
// sort the array from largest to smallest
>>> array.sort(function (a, b) { return a < b
[97, 34, 24, 18, 13, 5, 4, 2]</lang>
|