Defines an array of type int and arranges the number of them from small to large.
Train of thought: Take two numbers from the array to compare and keep the smallest value to compare with the other values in the group, get the minimum value, and put him first (I loop once, J makes all the comparisons of all values)
The first for loop can only complete the arrangement of a minimum value at a time, and when the loop completes, the sort is completed.
Public int[] Bubblesortball (int[] array) {//bubble sort, sort the numbers from small to large for (int i = 0; i < Array.Length; i++) {//Remove the first of the array A value
for (int j = i+1 J < array.length-1; J + +) {//Remove second value from array
if (Array[i]>array[j]) {//the size of two values is compared in the first loop, two values are interchanged if the first value is greater than the second value, otherwise the first value is compared with the value of the next loop
Array[i] = Array[i]^array[j];
ARRAY[J] = Array[i]^array[j]; Three times different or budget, the completion is worth exchanging.
Array[i] = Array[i]^array[j];
}
}
}
return array;
}