Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bubblesort;
- public class BubbleSort {
- public static int[] sort(int[] arrayToBeSorted){
- int aux = 0;
- boolean flag = true;
- while (flag == true){
- flag = false;
- for (int j = 0; j < arrayToBeSorted.length - 1 ; j++) {
- if (arrayToBeSorted[j] > arrayToBeSorted[j + 1]) {
- aux = arrayToBeSorted[j + 1];
- arrayToBeSorted[j + 1] = arrayToBeSorted[j];
- arrayToBeSorted[j] = aux;
- flag = true;
- }
- }
- }
- return arrayToBeSorted;
- }
- }
Add Comment
Please, Sign In to add comment