Sorts array elements numerically or alphanumerically.
True, if sort is successful; False, otherwise.
Array functions,
List functions
ArraySort(array, sort_type [, sort_order ])
New in ColdFusion MX: this function can throw the ArraySortSimpleValueException error and ValueNotNumeric error.
New in ColdFusion MX: in a textnocase
, descending sort, this function might return elements in a different sort order than in earlier releases. If sort_type = "textnocase"
and sort_order = "desc"
, ColdFusion MX processes elements that differ only in case differently from earlier releases, as follows:
For example, in a textnocase
, desc
sort of d,a,a,b,A
, the following occurs:
d,b,A,a,a
d,b,a,a,A
(In a textnocase
, asc sort, all ColdFusion releases return a,a,A,b,d
.)
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.
<!--- This example shows ArraySort ---> <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 isSuccessful = ArraySort(myArray, "textnocase", "desc")> ...