Skip to content

Instantly share code, notes, and snippets.

@happyduck-git
Created May 31, 2022 06:05
Show Gist options
  • Save happyduck-git/44e7ea134a997321a68a4b229d25b09b to your computer and use it in GitHub Desktop.
Save happyduck-git/44e7ea134a997321a68a4b229d25b09b to your computer and use it in GitHub Desktop.
public static void bubbleSort(int[] arr) {
for(int i = 0; i < arr.length - 1; i++) {
for(int j = 0; j < arr.length - i - 1; j++) {
if(arr[j] > arr[j+1]) {
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment