Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
public class bubblesort {
static void bubblesort(int[]arr) {
//Method for bubblesort
int a = arr.length;
//a to be replaced by array length once in use
int id = 0;
//Setting parameter
for(int x=0; x < (a - 1); x++)
//loop to access array values
{
for(int y=1; y < (a - x); y++)
//loop to identify number number after 'x' in array
{
if(arr[y-1] > arr[y])
//If statement to set condition
{
id = arr[y-1];
arr[y-1] = arr[y];
//Method to swap numbers depending on size in array
arr[y] = id;
}
}
}
}
}