Connecting Tech Pros Worldwide Forums | Help | Site Map

Max Number in List (Solution)

Member
 
Join Date: Jul 2006
Location: Virginia Beach, VA
Posts: 69
#1: Aug 8 '08
The delima was I had a list of numbers that I needed to find the maximum value of. Simply doing Max(ListName) did not work because the Max function requires only two parameters.

What I ended up doing to get around this was converting my list to an array and doing the ArrayMax function

<cfset myList = "1,3,1,2,5,2,2,3,2,3,4">
<cfset maxNum = ArrayMax(ListToArray(myList))>

I figured I'd share this since this seemingly small issue took me a good hour to figure out.

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Aug 8 '08

re: Max Number in List (Solution)


You can use a mixture of ListSort and ListFirst/ListLast rather than converting to an array.
Reply