ColdFusion Source Website Programming
         Powered by Aixen

 
             
 

 arrow Links

     Read ColdFusion Source
     XML / RSS Feed
     FeedBurner
     Who is Aixen?

 arrow Tag Cloud

 arrow ColdFusion Archive

   2008
     December
   0 posts   

     November
   0 posts   

     October
   0 posts   

     September
   0 posts   

     August
   0 posts   

     July
   0 posts   

     June
   1 posts   

     May
   1 posts   

     April
   0 posts   

     March
   0 posts   

     February
   0 posts   

     January
   0 posts   


   2007
     December
   1 posts   

     November
   0 posts   

     October
   0 posts   

     September
   0 posts   

     August
   0 posts   

     July
   0 posts   

     June
   0 posts   

     May
   0 posts   

     April
   0 posts   

     March
   0 posts   

     February
   0 posts   

     January
   0 posts   


 arrow Related Links

 arrow Photo Galleries

     View Photo Galleries

 arrow Recommended Sites

     Aixen Website Design
     LJP Construction
     Biodiesel Fueling Stations
     Enterprise Standards
     Bed & Bath Home Decor
     Ken Hanscom


   Google PageRank 
Checker - Page Rank Calculator
   Google Page Rank
 

ColdFusion: How to Sort Arrays or Lists Aplhabetically Alphabetize

Posted by Grant Powell on Monday, May 26, 2008 at 2:53 AM (PST)

This is actually really simple, but I stumbled across it, so I figured I would throw it up here:

If you have an array or list of text string elements that you want to sort alphabetically, ColdFusion has a built in function for just that - ArraySort or List Sort

Note: ArraySort only works with one dimensional arrays.  If you have multi-dimensional arrays that you want to sort, you should first concatenate the columns into one delimited list to store in a one dimensional array.  In other words, if you have:

MyArray = ArrayNew(2);
MyArray[1][1] = "x";
MyArray[1][2] = "hello";

... you will need to change this to:

MyArray = ArrayNew(1);
MyArray[1] = "x,hello";

... or something along those lines.  Ok, so back to the task at hand.  Sorting lists or one dimensional arrays is very simple.  See the code below:

<cfscript>
MySortedList = ListSort("x=hello&a=1&c=3&b=2", "textnocase", "ASC");

MyArray = ArrayNew(1);
MyArray[1] = "x=hello";
MyArray[2] = "a=1";
MyArray[3] ="c=3";
MyArray[4] = "b=2";

MySortedArray = ArraySort(MyArray, "text", "DESC");
</cfscript>

Here is some Adobe ColdFusion documentation on this matter: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000397.htm

Hope that is useful to some one.

 


 
             
© 2008 Aixen, Inc | All rights reserved | Privacy | Technorati | Blog Spot | Website Programming by Aixen
Website Last Updated on 9/7/2008