Excellent.  Thanks!

-----Original Message-----
From: News Sameli [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 11, 2004 9:46 AM
To: [EMAIL PROTECTED]
Subject: Re: [ cf-dev ] arraySort


Theres a UDF:

<!---
   
    This library is part of the Common Function Library Project. An open 
source
    collection of UDF libraries designed for ColdFusion 5.0. For more 
information,
    please see the web site at:
       
        http://www.cflib.org
       
    Warning:
    You may not need all the functions in this library. If speed
    is _extremely_ important, you may want to consider deleting
    functions you do not plan on using. Normally you should not
    have to worry about the size of the library.
       
    License:
    This code may be used freely.
    You may modify this code as you see fit, however, this header, and 
the header
    for the functions must remain intact.
   
    This code is provided as is.  We make no warranty or guarantee.  Use 
of this code is at your own risk.
--->

<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>


Sam wrote:

>quick question... is there an easy way of sorting a 2 dimensional 
>array?
>
>arraySort only works on 1 dimensional arrays, it seems.
>
>  _____
>
>Sam Clement
>ABOVE Studios
>Boutique Design Solutions
>
>32 Clifford Street - Belmont
>Trinidad + Tobago - West Indies
>T: (868) 621 5159 W: abovestudios.com
>
> 
>
>
>  
>



-- 
These lists are syncronised with the CFDeveloper forum at
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
 
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided
by activepdf.com*
      *Forums provided by fusetalk.com* :: *ProWorkFlow provided by
proworkflow.com*
           *Tutorials provided by helmguru.com* :: *Lists hosted by
gradwell.com*

To unsubscribe, e-mail: [EMAIL PROTECTED]



-- 
These lists are syncronised with the CFDeveloper forum at 
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
 
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by 
activepdf.com*
      *Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
           *Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*

To unsubscribe, e-mail: [EMAIL PROTECTED]

Reply via email to