//SORT THE LIST IN ASCENDING ORDER USING BUBBLE SORT – JAVA
class Bubblesort
{
public static void main(String args[ ])
{
int a[ ]={7,3,9,1,2,43,23,10};
int i,j,l,temp;
l=a.length;
System.out.println(“Elements in the unsorted array are: “);
for(i=0;i<l;i++)
{
System.out.println(a[i]+”\t”); //PRINTING UNSORTED ELEMENTS
}
for(i=0;i<l;i++) //SORTING THE ELEMENTS IN ARRAY
{
for(j=0;j<l-i-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
System.out.println(“Sorted array elements are: “);
for(i=0;i<l;i++)
{
System.out.println(a[i]+”\t”); ////PRINTING SORTED ELEMENTS
}
}
}