Guest User

Untitled

a guest
Oct 17th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. package bubblesort;
  2.  
  3. public class BubbleSort {
  4. public static int[] sort(int[] arrayToBeSorted){
  5. int aux = 0;
  6. boolean flag = true;
  7.  
  8. while (flag == true){
  9. flag = false;
  10.  
  11. for (int j = 0; j < arrayToBeSorted.length - 1 ; j++) {
  12. if (arrayToBeSorted[j] > arrayToBeSorted[j + 1]) {
  13. aux = arrayToBeSorted[j + 1];
  14. arrayToBeSorted[j + 1] = arrayToBeSorted[j];
  15. arrayToBeSorted[j] = aux;
  16. flag = true;
  17. }
  18. }
  19. }
  20.  
  21. return arrayToBeSorted;
  22. }
  23. }
Add Comment
Please, Sign In to add comment