Search
IEnumerable.sort Method
See Also
 






Sorts the underlying array.

Namespace: MindFusion.Common.Collections
File: IEnumerable.js

 Syntax

JavaScript  Copy Code

function sort ([compareFn])

 Parameters

compareFn
Optional.

function. The comparing function.

 Example

The following code sorts a List with product instances based on the price of each one:

JavaScript  Copy Code

var product1 = new Object();
product1.title = "Ford";
product1.price = 25345;

var product2 = new Object();
product1.title = "BMW";
product1.price = 75300;

productList.addRange([product1, product2]);


productList.items().sort(function (a, b)
{
      return a.price - b.price.valueOf();
});

 See Also