Thanks Alan that worked, here is the final code that made it work for my 
situation:

<cfscript>
/**
 * Sorts a two dimensional array by the specified column in the second 
dimension.
 * 
 * @return Returns an array. 
 * @author Robert West ([email protected]) 
 * @version 1, October 8, 2002 
 */
function ArraySort2D(arrayToSort, sortColumn, type) {
    var order = "asc";
    var i = 1;
    var j = 1;
    var thePosition = "";
    var theList = "";
    var arrayToReturn = ArrayNew(2);
    var sortArray = ArrayNew(1);
    var counter = 1;
    if (ArrayLen(Arguments) GT 3){
        order = Arguments[4];
    }
    for (i=1; i LTE ArrayLen(arrayToSort); i=i+1) {
        ArrayAppend(sortArray, arrayToSort[i][sortColumn]);
    }
    theList = ArrayToList(sortArray);
    ArraySort(sortArray, type, order);
    for (i=1; i LTE ArrayLen(sortArray); i=i+1) {
        thePosition = ListFind(theList, sortArray[i]);
        theList = ListDeleteAt(theList, thePosition);
        for (j=1; j LTE ArrayLen(arrayToSort[thePosition]); j=j+1) {
            arrayToReturn[counter][j] = arrayToSort[thePosition][j];
        }
        ArrayDeleteAt(arrayToSort, thePosition);
        counter = counter + 1;
    }
    return arrayToReturn;
}
</cfscript>

<cfset startArray = ArrayNew(2)>
<cfset startArray[1][1] = "11/10/11">
<cfset startArray[1][2] = "hello">
<cfset startArray[2][1] = "12/5/11">
<cfset startArray[2][2] = "cool">
<cfset startArray[3][1] = "1/4/11">
<cfset startArray[3][2] = "nice">

<cfoutput>

<cfloop from="1" to="#ArrayLen(startArray)#" index="i">
    <cfloop from="1" to="#ArrayLen(startArray[i])#" index="j">
        startArray[#i#][#j#] is #startArray[i][j]#<br>    </cfloop>
</cfloop>
</p>

<cfset finalArray = #ArraySort2D(startArray, 1, "numeric")#>

<p>
<cfloop from="1" to="#ArrayLen(finalArray)#" index="i">
    <cfloop from="1" to="#ArrayLen(finalArray[i])#" index="j">
        finalArray[#i#][#j#] is #finalArray[i][j]#<br>
    </cfloop>
</cfloop>
</p>
</cfoutput> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:348198
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to