public class test {
public static void main(String[] args) {
long[] arr = {45,34,23,12,1};
sort(arr);
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
/**
* 冒泡排序
* @param arr
*/
public static void sort(long[] arr){
long temp = 0;
for (int i = 0; i < arr.length-1; i++) {
for (int j = arr.length-1;j>i;j--){
if (arr[j]<arr[j-1]){
temp = arr[j];
arr[j]=arr[j-1];
arr[j-1]=temp;
}
}
}
}
}