java numerical bubble sort

class Water

{

public void water(int array[])

{

 

int temp;

//Sort The external sorting logarithm performs array.length-1 loops, and the number of loops starts from 0

for(int i=0;i<array.length-1;i++)

{

//Internal sorting compares the two adjacent numbers in each pass to make the smaller value sink to the bottom 

for(int j=0; j<array.length-i-1;j++)

{

if(array[j]>array[j+1])

{

temp = array[j];

array[j]= array[j+1];

array[j+1]= temp;

 

}

}

}

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326403726&siteId=291194637