Notice: With the launch of Adobe Cookbooks, this site will no longer be accepting new entries or posting new content. Thanks to everyone who submitted content!

How do I sort a single dimension array?

Use the built in ColdFusion arraySort() function.

<cfset arr = arrayNew(1)>
<cfset arr[1] = "beta">
<cfset arr[2] = "bar">
<cfset arr[3] = "foo">
<cfset arr[4] = "alpha">

<!--- sort array ascending alphabetically --->
<cfset isSuccessful = ArraySort(arr, "textnocase", "asc")>

<cfdump var="#arr#">


This question was written by Jeremy Petersen.
It was last updated on May 8, 2006 at 2:57:02 PM EDT.

CFML Referenced

ArraySort()

Categories

Data Structures

Comments

There are no comments for this entry.