ARRAYSORT | |
Description
Sorts array elements numerically or alphanumerically. |
|
Returns
True, if sort is successful; False, otherwise. |
|
Category
Array functions, List functions |
|
Function syntaxArraySort(array, sort_type [, sort_order ]) |
|
History
ColdFusion MX:
For example, in a textnocase, desc sort of d,a,a,b,A, the following occurs: |
|
Parameters
|
|
Throws
If an array element is other than a simple element, this function throws an ArraySortSimpleValueException error. If sort_type is numeric and an array element is not numeric, this function throws a ValueNotNumeric error. |
|
Example<!--- This example shows ArraySort ---> <cfquery name = "GetEmployeeNames" datasource = "cfdocexamples"> 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 isSuccessful = ArraySort(myArray, "textnocase", "desc")> ... |
ARRAY | |
SORT_TYPE | |
SORT_ORDER | |