Created
July 30, 2021 13:22
-
-
Save bodrulamin/ddf4acb62a93350a5b6753a569f43101 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int[] bubbleSort(int[] list) { | |
boolean needNextPass = true; | |
for (int i = 1; i < list.length && needNextPass; i++) { | |
needNextPass = false; | |
for (int j = 0; j < list.length - i; j++) { | |
if (list[j] > list[j + 1]) { | |
int big = list[j]; | |
list[j] = list[j + 1]; | |
list[j + 1] = big; | |
needNextPass = true; | |
} | |
} | |
} | |
return list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment