选择排序和冒泡排序时间复杂度都是O(n^2),
java,Arrys类中的sort快排时间复杂度是O(n*log(n));

手写选择排序和冒泡排序:

class SelectSort{
	public static void main(String[] args){
		int[] arr1 = {83,3,45,12,34,19,77,66};
		int[] arr2 = {4,34,77,56,65,78,87,98,100};
		selectSort(arr1);//选择排序
		printArr(arr1);
		System.out.println();
		bubbleSort(arr2);//冒泡排序
		printArr(arr2);		
	}
	
	//选择排序:
	public static void selectSort(int[] arr){
		for(int i= 0;i<arr.length-1;i++)
		{
			for(int j=i+1;j<arr.length;j++)
			{
				if(arr[i] > arr[j])
				{
					/* int temp = arr[j]; arr[j] = arr[i]; arr[i] = temp; */
					swap(arr,i,j);
				}
			}
		}
	}
	
	//冒泡排序
	public static void bubbleSort(int[] arr){
		for(int i=arr.length-1;i>0; i--)
		{
		   for(int j=0; j<i; j++)
		   {
				if(arr[j] > arr[j+1])
				{
					//int temp = arr[j+1];
					//arr[j+1] = arr[j];
					//arr[j] = temp;
					swap(arr, j, j+1);
				}
			}
		}
	}
	
	//打印数组
	public static void printArr(int[] arr){
		for(int i=0;i<arr.length;i++)
		{
			System.out.print(arr[i]+" ");
		}
	}
	
	//交换数组中两个位置
	public static void swap(int[] arr, int from, int to){
		int temp = arr[from];
		arr[from] = arr[to];
		arr[to] = temp;
	}
}


调用Arrays类的快排:

import java.util.Arrays;
class SortDemo{
	public static void main(String[] args){
		int[] arr1 = {9,1,2,4,7,3,8,6,5};	
		int[] arr2 = {78,98,77,56,65,34,4,87,98,32};
		Arrays.sort(arr1);//整体排序
		Arrays.sort(arr2,2,7);//局部范围排序[ )
			
		//下面是输出
		for(int i=0;i<arr1.length;i++)
		{
			System.out.print(arr1[i]+" ");
		}
		System.out.println();		
		for(int i=0;i<arr2.length;i++)
		{
			System.out.print(arr2[i]+" ");
		}		
		
	}
}

遗憾的是sort快排并不支持降序排序。但是我们可以升序排列后手动转为降序,也可以用包裹类型降序排列。