Friday, June 25, 2010

Finding the min and max element in an Array in Flex

What would be a really good way to find min and max elements in Flex
in an array, other than looping?

Answer :
var myArray:Array = [2,3,3,4,2,2,5,6,7,2];
myArray.sort(Array.NUMERIC);
var minValue:int = myArray[0];
var maxValue:int = myArray[myArray.length-1]

No comments:

Blog Archive