public int sort int int left int right length do for int left right if

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public int[] sort(int[] a) {
int left = 0;
int right = a.length - 1;
do {
for (int i = left; i < right; i++) {
if (a[i] > a[i + 1]) {
int tmp = a[i + 1];
a[i + 1] = a[i];
a[i] = tmp;
}
}
right--;
for (int i = right; i > left; i--) {
if(a[i]<a[i-1]){
int tmp = a[i - 1];
a[i - 1] = a[i];
a[i] = tmp;
}
}
left++;
} while (left <= right);
return a;
}