Revision: 43236
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 19, 2011 23:14 by kanuwadhwa
Initial Code
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ public var arr:Array = new Array("-23", "-12", "45", "22", "-42", "87", "97", "13","24","-10", "-2", "5") public function init():void{ arr.sort(Array.NUMERIC); for(var i=0;i<arr.length;i++){ txt.text += "\n "+arr[i]; if(arr[i]<0) { var min:Number = arr[i]; } if(arr[arr.length -i-1]>0){ var max:Number = arr[arr.length -i-1]; } } txt.text += "\n closet +ive number to 0>> "+max+" << closest -ive number to 0 >>"+min; } ]]> </mx:Script> <mx:TextArea x="118" y="57" width="553" height="412" id="txt"/> </mx:Application>
Initial URL
Initial Description
Looking forward for the most optimized solution for the same
Initial Title
2 closest numbers to 0
Initial Tags
actionscript, flash, Flex
Initial Language
ActionScript 3