Skip to content

Instantly share code, notes, and snippets.

@yaboong
Created October 26, 2019 08:19
Show Gist options
  • Save yaboong/ee8d1a929d7a012d661aa2bda62ec744 to your computer and use it in GitHub Desktop.
Save yaboong/ee8d1a929d7a012d661aa2bda62ec744 to your computer and use it in GitHub Desktop.
public static void sort(Integer[] a) {
int swapCount;
do {
swapCount = 0;
for (int i=1; i<a.length; i++) {
if (a[i-1] > a[i]) {
swap(a, i-1, i);
swapCount++;
}
}
} while (swapCount != 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment