Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int[] bubbleSort(int[] a1){
- int i = 0;
- int element = 0;
- int element2 = 0;
- if (a1.length < 2) {
- return a1;
- }
- do{
- i++;
- if (a1[i] < a1[i - 1]) {
- element = a1[i];
- element2 = a1[i - 1];
- a1[i - 1] = element;
- a1[i] = element2;
- }
- } while (i < a1.length - 1);
- return a1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement