Sorts and delimits the items in a list according to a sort type and sort order.
ListSort(list, sort_type [, sort_order] [, delimiter ])
ColdFusion ignores empty list elements; thus, a list that is defined as "a,b,c,,,d" is treated as a four element list.
<!--- This example shows how to use ListSort--->
<html>
<head>
<title>ListSort Example</title>
</head>
<body>
<H3>ListSort Example</H3>
<!--- Find a list of users who wrote messages --->
<cfquery name = "GetMessageUser" datasource = "cfsnippets">
SELECT Username, Subject, Posted
FROM Messages
</cfquery>
<cfset myList = ValueList(GetMessageUser.UserName)>
<P>Here is the unsorted list. </P>
<cfoutput>
#myList#
</cfoutput>
<P>Here is the list sorted alphabetically:</P>
<cfset sortedList = ListSort(myList, "Text")>
<cfoutput>
#sortedList#
</cfoutput>
<P>Here is a numeric list that is to be sorted in descending order.</P>
<cfset sortedNums = ListSort("12,23,107,19,1,65","Numeric", "Desc")>
<cfoutput>
#sortedNums#
</cfoutput>
<P>Here is a list that must be sorted numerically, since it
contains negative and positive numbers, as well as decimal numbers. </P>
<cfset sortedNums2 = ListSort("23.75;-34,471:100,-9745","Numeric", "ASC", ";,:")>
<cfoutput>
#sortedNums2#
</cfoutput>
<P>Here is a list to be sorted alphabetically without consideration
of case.</P>
<cfset sortedMix =
ListSort("hello;123,HELLO:jeans,-345,887;ColdFusion:coldfusion",
"TextNoCase", "ASC", ";,:")>
<cfoutput>
#sortedMix#
</cfoutput>
</body>
</html>