Array.sort()
Top  Previous  Next


SWiSH Player Support
SWF5 or later - Supported Internally

Syntax
arrayName.sort();

Arguments
None.

Returns
Nothing.

Description
Method; sorts the elements of an array using the < (less than) comparison operator. This can be used to sort elements of an array numerically or alphabetically.

Samples
onLoad() {
  
  myNumbers = new Array("5","2","1","3");
  
  myNumbers.sort();
  
  trace(myNumbers.join());
}

// displays "1,2,3,5" in the debug window


onLoad() {
  
  team = new Array("John","Brian","Alison","Stephan");
  
  team.sort();
  
  trace(team.join());
}

// displays "Alison,Brian,John,Stephan" in the debug window