<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>ARRAYSORT</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">ARRAYSORT</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 array elements numerically or alphanumerically. 
</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>
True, if sort is successful; False, otherwise.
</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>
Array functions, 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>ArraySort(array, sort_type [, sort_order ])
</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">History</span>
<p>
ColdFusion&#160;MX: 
</p>
<ul>

<li>Changed thrown exceptions: this function can throw the ArraySortSimpleValueException error and ValueNotNumeric error.</li>

<li>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, as follows:</li>
<ul>

<li>ColdFusion&#160;MX reverses the elements' original order.</li>

<li>Earlier releases of ColdFusion do not change the elements' original order.</li>

<p>
For example, in a textnocase, desc sort of d,a,a,b,A, the following occurs:
</p>
    </td>
  </tr>
<li>ColdFusion&#160;MX returns d,b,A,a,a</li>

<li>Earlier ColdFusion releases return d,b,a,a,A</li>
</ul>
</ul>
    </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">Throws</span>
<p>
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.
</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;!--- This example shows ArraySort ---&gt;
&lt;cfquery name = &quot;GetEmployeeNames&quot; datasource = &quot;cfdocexamples&quot;&gt;
SELECT FirstName, LastName FROM Employees
&lt;/cfquery&gt;
&lt;!--- create an array ---&gt;
&lt;cfset myArray = ArrayNew(1)&gt;
&lt;!--- loop through the query and append these names successively to the last
element ---&gt;
&lt;cfloop query = &quot;GetEmployeeNames&quot;&gt;
   &lt;cfset temp = ArrayAppend(myArray, &quot;#FirstName# #LastName#&quot;)&gt;
&lt;/cfloop&gt;
&lt;!--- show the resulting array as a list ---&gt;
&lt;cfset myList = ArrayToList(myArray, &quot;,&quot;)&gt;
&lt;!--- sort that array descending alphabetically ---&gt;
&lt;cfset isSuccessful = ArraySort(myArray, &quot;textnocase&quot;, &quot;desc&quot;)&gt;
...
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="ARRAY">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">ARRAY</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>Name of an array </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>&#160;- aabzABZ, if sort_order = &quot;asc&quot; (ascending sort)</p>
<p>&#160;- 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>&#160;- aAaBbBzzZ, in an ascending sort; preserves original intra-letter order </p>
<p>&#160;- 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>&#160;- aabzABZ or aAaBbBzzZ, depending on value of sort_type, for letters</p>
<p>&#160;- from smaller to larger, for numbers </p><ul>

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

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

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

  </body>
</html>
