//Following is the program to arrange the elements of an array in ascending order:
class nm
{
public static void main(String args [ ])
{
int i,j;
int a[ ]={1,2,3,46,8};
int n=a.length;
System.out.println(“LENGTH OF ARRAY IS=”+n);
System.out.println(“GIVEN LIST”);
for(i=0;i<=n;i++)
{
System.out.println(“ “+ a[i]);
}
for(i=0;i<=n;i++)
{
for(j=0;j<=n;j++)
{
if(a[i]<a[j])
{
int temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
System.out.println(“SORTED LIST”);
for(i=0;i<=n;i++)
{
System.out.println(“\n”+a[i]);
}
}
}