Hello all, im looking for a way to determine which number is the greatest out of a list of variables. Has anyone seen any sort of class or function that can do this?
basically i have about 10 variables that are numbers. i want to find which one has the greatest value. or which ones have the greatest tied number.
If you put your values into an array (called myArray, say)
then the largest value = arrayMaximum(myArray)
where arrayMaximum is the following function:
function arrayMaximum(yourArray:Array):Number
{
var maximum:Number = yourArray[0];
for(var i:int = 1; i < yourArray.length(); i++)
{
if(yourArray* > maximum)
{
maximum = yourArray*;
}
}
return maximum;
}
I was thinking similar but using Array.sort(Array.NUMERIC); to make your number sort by number lowest to highest.
Yes, of course.
That’s a neater way of doing it.
(I always forget there’s a sort method for arrays.)