<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>LISTSORT</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="Description">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">LISTSORT</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Description</span>
<p>
Sorts list elements according to a sort type and sort order. 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Returns</span>
<p>
A copy of a list, sorted.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Category</span>
<p>
List functions
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Function syntax</span><pre>ListSort(list, sort_type [, sort_order] [, delimiters ])
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">See also</span>
<p>
"Lists" in Chapter&#160;3, "Using ColdFusion Variables," in ColdFusion MX Developer's Guide 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">History</span>
<p>
ColdFusion&#160;MX: Changed the order in which sorted elements are returned: in a textnocase, descending sort, this function might return elements in a different sort order than in earlier releases. If sort_type = &quot;textnocase&quot; and sort_order = &quot;desc&quot;, ColdFusion&#160;MX processes elements that differ only in case differently from earlier releases. ColdFusion&#160;MX outputs the elements in the reverse of the ascending order. Earlier releases do not change order of elements that differ only in case. Both operations are correct. The new operation ensures that an ascending and descending sort output elements in exactly reverse order.
</p>

<p>
For example, in a textnocase, desc sort of d,a,a,b,A, the following occurs:
</p>
<ul>

<li>ColdFusion&#160;MX returns d,b,A,a,a</li>

<li>Earlier ColdFusion releases return d,b,a,a,A</li>
</ul>

<p>
(In a textnocase, asc sort, all ColdFusion releases return a,a,A,b,d.)
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Parameters</span>
<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Usage</span>
<p>
ColdFusion ignores empty list elements; thus, the list &quot;a,b,c,,,d&quot; has four elements.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Example</span><pre>&lt;h3&gt;ListSort Example&lt;/h3&gt;

&lt;!--- Find a list of users who wrote messages ---&gt;
&lt;cfquery name = &quot;GetMessageUser&quot; datasource = &quot;cfdocexamples&quot;&gt;
SELECT&#160;&#160;&#160;Username, Subject, Posted
FROM&#160;&#160;&#160;&#160;&#160;Messages
&lt;/cfquery&gt;

&lt;cfset myList = ValueList(GetMessageUser.UserName)&gt;
&lt;p&gt;Here is the unsorted list. &lt;/p&gt;
&lt;cfoutput&gt;#myList#
   &lt;/cfoutput&gt;
&lt;p&gt;Here is the list sorted alphabetically:&lt;/p&gt;
&lt;cfset sortedList = ListSort(myList, &quot;Text&quot;)&gt;
&lt;cfoutput&gt;#sortedList#
   &lt;/cfoutput&gt;

&lt;p&gt;Here is a numeric list that is to be sorted in descending order.&lt;/p&gt;
&lt;cfset sortedNums = ListSort(&quot;12,23,107,19,1,65&quot;,&quot;Numeric&quot;, &quot;Desc&quot;)&gt;
&lt;cfoutput&gt;#sortedNums# &lt;/cfoutput&gt;

&lt;p&gt;Here is a list that must be sorted numerically, since it contains 
negative and positive numbers, and decimal numbers. &lt;/p&gt;
&lt;cfset sortedNums2 = ListSort(&quot;23.75;-34,471:100,-9745&quot;,&quot;Numeric&quot;, &quot;ASC&quot;, 
&quot;;,:&quot;)&gt;
&lt;cfoutput&gt;#sortedNums2# &lt;/cfoutput&gt;

&lt;p&gt;Here is a list to be sorted alphabetically without consideration of case.&lt;/
p&gt;
&lt;cfset sortedMix =
   ListSort(&quot;hello;123,HELLO:jeans,-345,887;ColdFusion:coldfusion&quot;,
      &quot;TextNoCase&quot;, &quot;ASC&quot;, &quot;;,:&quot;)&gt;
&lt;cfoutput&gt;#sortedMix# &lt;/cfoutput&gt;
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="LIST">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">LIST</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>A list or a variable that contains one.</p>

  </td>
  </tr>
  </table>
</div>
<div id="SORT_TYPE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">SORT_TYPE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

<ul>

<li>numeric: sorts numbers</li>

<li>text: sorts text alphabetically, taking case into account (also known as case sensitive). All letters of one case precede the first letter of the other case:</li>
</ul>

<p>	- aabzABZ, if sort_order = &quot;asc&quot; (ascending sort)</p>
<p>	- ZBAzbaa, if sort_order = &quot;desc&quot; (descending sort)</p><ul>

<li>textnocase: sorts text alphabetically, without regard to case (also known as case-insensitive). A letter in varying cases precedes the next letter:</li>
</ul>

<p>	- aAaBbBzzZ, in an ascending sort; preserves original intra-letter order </p>
<p>	- ZzzBbBaAa, in a descending sort; reverses original intra-letter order </p>

  </td>
  </tr>
  </table>
</div>
<div id="SORT_ORDER">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">SORT_ORDER</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

<ul>

<li>asc - ascending sort order. Default.</li>
</ul>

<p>	- aabzABZ or aAaBbBzzZ, depending on value of sort_type, for letters</p>
<p>	- from smaller to larger, for numbers </p><ul>

<li>desc - descending sort order.</li>
</ul>

<p>	- ZBAzbaa or ZzzBbBaAa, depending on value of sort_type, for letters</p>
<p>	- from larger to smaller, for numbers </p>

  </td>
  </tr>
  </table>
</div>
<div id="DELIMITERS">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">DELIMITERS</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>A string or a variable that contains one. Character(s) that separate list elements. The default value is comma. </p>
<p>If this parameter contains more than one character, ColdFusion uses the first character in the string as the delimiter, and ignores the rest.</p>

  </td>
  </tr>
  </table>
</div>

  </body>
</html>
