sivaramaiah  
 
  Record20 07/16/2018 7:01am (UTC)
   
 
Record 20 : Sorting and Reversing of an Array
var a=new Array(5);
a=[4,7,2,18,10];
ascend(a);
descend(a);
var i,j,temp=0;
function ascend(a:Number):Void
{
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(a[i]<a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
trace("Ascending order of given numbers is:");
for(i=0;i<5;i++)
{
trace(a[i]);
}
}
function descend(a:Number):Void
{
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
trace("Descending order of given numbers is:");
for(i=0;i<5;i++)
{
trace(a[i]);
}
}


-----------------------------------------------------------------------------
output
----------------------------------------------------------------------------
Ascending order of given numbers is:
2
4
7
10
18
Descending order of given numbers is:
18
10
7
4
2



 
  Menu Items
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

  add
HOT TOPICS
MCA PROJECT DETAILS ------------------------------------- Jntu all Lab manuals ------------------------------------- Jntu Syllabus Books ------------------------------------- Paper presentations ------------------------------------- Seminars ------------------------------------- Campus Papers ------------------------------------- Competetive Exams GATE ------------------------------------- GRE ------------------------------------- TOEFL ------------------------------------- IELTS ------------------------------------- CAT ------------------------------------- GMAT ------------------------------------- Templates ------------------------------------- Students Resume Preparation tips ------------------------------------- Job zone(Interview questions) ------------------------------------- Google Adsence html code ------------------------------------- Web sites --------x--------------x-----------
  Advertisement
  Advertisement

 


-----------------------------
  Offline Messages
  Adds
  Visitors Information
Today, there have been 70379 visitors (198390 hits) on this page!
=> Do you also want a homepage for free? Then click here! <= --------------------------------------------------