# ArraySort

Returns the specified array with elements numerically or alphanumerically sorted.

### Syntax

    ArraySort(array, sort_type [, sort_order ])

##### array

Name of the array you want to sort.

##### sort_type

The type of sort to execute. Sort type can be:

- `numeric` -- Sorts numerically
- `text` -- Sorts text alphabetically, uppercase before lowercase
- `textnocase` -- Sorts text alphabetically; case is ignored

##### sort_order

The sort order you want to enforce:

- `asc` -- (Default) Ascending sort order
- `desc` -- Descending sort order

### Example

    <!--- This example shows ArraySort --->

    <HTML>
    <HEAD>
    <TITLE>ArraySort Example</TITLE>
    </HEAD>

    <BODY>
    <CFQUERY NAME="GetEmployeeNames" DATASOURCE="cfsnippets">
    SELECT FirstName, LastName FROM Employees
    </CFQUERY>
    <!--- create an array --->
    <CFSET myArray = ArrayNew(1)>
    <!--- loop through the query and append these names
    successively to the last element --->
    <CFLOOP query="GetEmployeeNames">
        <CFSET temp= ArrayAppend(myArray, "#FirstName# #LastName#")>
    </CFLOOP>
    <!--- show the resulting array as a list --->
    <CFSET myList=ArrayToList(myArray, ",")>
    <!--- sort that array descending alphabetically --->
    <CFSET myAlphaArray = ArraySort(myArray, "textnocase", "desc")>
    ...