ArraySort

Returns the specified one-dimensional array with elements numerically or alphanumerically sorted.

Syntax

ArraySort(array, sort_type [, sort_order ])
array

Name of the one-dimensional array that you want to sort.

sort_type

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

sort_order

The sort order you want to enforce:

Example

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

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

<BODY>
<CFQUERY NAME="GetEmployeeNames" DATASOURCE="HRApp">
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")>
...