sivaramaiah  
 
  Record20 04/20/2024 4:12pm (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

 


-----------------------------
  Offline Messages
  Adds
  Visitors Information
Today, there have been 119634 visitors (281428 hits) on this page!
-------------------------------------------------- This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free