sort the list in descending order using bubble sort – JAVA

//program to sort the list in descending order using bubble sort.
class ListDescending
{
public static void main(String ar[])
{
int L[]={22,3,11,56,8},i,j,s;
for(i=0;i<L.length;i++)
{
for(j=0;j<L.length-i-1;j++)
{
if(L[j]<L[j+1])
{
s=L[j];
L[j]=L[j+1];
L[j+1]=s;
}
}
}

for(j=0;j<L.length;j++)
{
System.out.println(L[j]);
}
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *