public int[] BubbleSort(int[] arr) {
for (int i = 0; i < arr.length - 1; i++) {
for (int j = 0; j < arr.length - 1 - i; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
return arr;
}
public int[] InsertSort(int[] arr) {
for (int i = 0; i < arr.length; i++) {
for (int j = i - 1; j >= 0 && arr[j] > arr[j + 1]; j--) {
swap(arr, j, j + 1);
}
}
return arr;
}
private static void swap(int[] arr, int j, int i) {
arr[i] = arr[i] ^ arr[j];
arr[j] = arr[i] ^ arr[j];
arr[i] = arr[i] ^ arr[j];
}
public int[] MySort (int[] arr) {
for (int i = 0; i < arr.length-1; i++) {
int minIndex=i;
for (int j = i+1; j < arr.length ; j++) {
minIndex= arr[minIndex]>arr[j] ? j:minIndex;
}
swap(arr,minIndex,i);
}
return arr;
}
public static void swap(int[] arr,int i,int j){
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}