# Sorting Arrays : Sort « Array « Flash / Flex / ActionScript

Sorting Arrays

```
//sort() sorts regular, single dimension arrays.
//sortOn() sorts arrays of associative arrays based on one of the keys of the associative arrays.
//reverse() reverses the order of the elements.

package{
import flash.display.Sprite;

public class Main extends Sprite{
public function Main(){
var aEmployees:Array = ["A", "P", "C", "H"];
aEmployees.sort();
trace(aEmployees.toString());

}
}
}
A,C,H,P

```

### Related examples in the same category

 1 Sorting Numerically: Array.NUMERIC 2 Sorting in Descending Order 3 Sorting Regardless of Case 4 A case-insensitive sort using the Array.CASEINSENSITIVE constant 5 Sorting and Testing for Unique Values 6 Getting Sorted Indices 7 Sorting with Multiple Flags 8 Sorting with Custom Algorithms 9 Sort the array's values first according to the type of value and then alphabetically 10 Sort an array in descending order using the Array.DESCENDING constant: 11 sort( ) method runs a case-sensitive sort by default 12 Use the Array.CASEINSENSITIVE constant to run a case-insensitive sort: 13 When you sort an array of numbers, the values are sorted according to the ASCII equivalents of the digits 14 Use the Array.NUMERIC constant with the sort( ) method to sort an array of numbers numerically 15 Sort the array only if it contains unique elements: Array.UNIQUESORT 16 Get the sorted order of an array's elements without changing the original array: Array.RETURNINDEXEDARRAY 17 Combine the combine the constants using the bitwise OR operator (|) 18 Reverse the order of the elements in an array 19 Call the sort( ) method passing the bandNameSort compare function: 20 Randomizing the Elements of an Array 21 Getting the Minimum or Maximum Element