Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BubbleSort{
- public void sort(int[] inArray) {
- for (int i = inArray.length - 1; i > 0; i--) {
- boolean sortFlag = true;
- for (int j = 0; j < i; j++) {
- if (inArray[j] > inArray[j + 1]) {
- sortFlag = false;
- int temp = inArray[j];
- inArray[j] = inArray[j + 1];
- inArray[j + 1] = temp;
- }
- }
- if (sortFlag) return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment