Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Bubble Sort in Java
public static void bubbleSort(int[] inputData) {
int inputDataLength = inputData.length;
while (inputDataLength != 0) {
int newn = 0;
for (int forwardPointer = 1; forwardPointer < inputData.length - 1; forwardPointer++) {
if(inputData[forwardPointer - 1] > inputData[forwardPointer]) {
final int temp = inputData[forwardPointer - 1];
inputData[forwardPointer - 1] = inputData[forwardPointer];
inputData[forwardPointer] = temp;
newn = forwardPointer;
}
}
inputDataLength = newn;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.