[thelist] CF: reversing a list

Raymond Camden jedimaster at macromedia.com
Mon Jun 18 07:07:27 CDT 2001


If you have CF5, you can use this UDF (from StrLib at www.cflib.org):

/*
ListReverse(list,[delims])
Function to reverse the order of a list
Stephen Milligan aka Spike (spike at spike.org.uk) - April 6, 2001
*/
function ListReverse(list) {

	var newlist = "";
	var i = 0;
	var argc = ArrayLen(arguments);
	if (argc EQ 1) {
	ArrayAppend(arguments,',');
	}
	delims = arguments[2];
	while (i LT listlen(list,delims))
{
	thisindex = listlen(list,delims)-i;
	thisitem = listgetat(list,thisindex,delims);
    newlist = listappend(newlist,thisitem,delims);
    i = i +1;
}
 return newlist;
}

=======================================================================
Raymond Camden, Principal Spectra Compliance Engineer for Macromedia

Email   : jedimaster at macromedia.com
ICQ UIN : 3679482

"My ally is the Force, and a powerful ally it is." - Yoda

> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org]On Behalf Of Isaac Forman
> Sent: Monday, June 18, 2001 3:01 AM
> To: thelist at lists.evolt.org
> Subject: [thelist] CF: reversing a list
>
>
>
> Hi,
>
> When using ColdFusion, what's the best way to reverse a list?
> There appears
> to be no such thing as listreverse().
>
> reverse() obviously reverses everything exactly (including list
> values). ie,
> "28,27" becomes "72,82".
>
> I tried browsing the CF forum (appears to have moved to Macromedia's site)
> but it looks empty.
>
>
> isaac
>
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !





More information about the thelist mailing list