OpenWGA 7.11 - TMLScript reference

WGA » WGA.List()
Method :

sortList([function])

On object WGA.List()
Usage

Sorts the list elements according to a custom compare function.

Description

The function parameter is optional. If not specified the elements will be sorted by "natural oder" if possible (like numbers) or converted to strings and sorted alphabetically.

The function is called with a pair of values to be compared and should return -1, 0 or 1.

Parameters

function (optional)

JavaScrpt function to compare value pairs.

Return value

WGAList object with new values.

Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Examples

WGA.List([1, 3, 2]).sortList()
//returns [1,2,3]

WGA.List([1,3,2]).sortList(function(a,b){ return a<b ? -1 : a==b ? 0: 1 }) //returns [1,2,3]