PP.numberSortAsc

Syntax

numberSortAsc(a, b);

Parameters

a. First value.

b. Second value.

Description

The numberSortAsc method represents function for ascending sorting.

Comments

This method is used as a parameter of the standard JavaScript function named sort.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Determine an array of integers and sort them in ascending order:

// Determine an integer array
var elements = [5, 9, 6, 7, 2];
console.log("Source array of elements: [" + elements + "]");
// Sort array elements in ascending order
elements.sort(PP.numberSortAsc);
console.log("Array of elements sorted in ascending order: [" + elements + "]");

After executing the example the browser console displays array elements sorted in ascending order:

Initial array of elements: [5,9,6,7,2]
Array of elements sorted in ascending order: [2,5,6,7,9]

See also:

PP