# Sort

```BubbleSort.Java

package sort;

public class BubbleSort {

public static void main(String[] args) {
int[] number={6,7,8,5,4,1,2,3};
//		bubbleSort(number);
int low=0;
int high=number.length-1;
quickSort(number,low,high);
//print
for(int i=0;i<number.length;i++)
System.out.print(number[i]+" ");
}
//bubbleSort

public static  void bubbleSort(int[] number) {
int tempt;
boolean continueSort=true;
while(continueSort){
continueSort=false;
for(int i=0;i<number.length-1;i++){
if(number[i]>number[i+1]){
tempt=number[i+1];
number[i+1]=number[i];
number[i]=tempt;
continueSort=true;
}
}
}
}
//recursion quickSort
private static void quickSort(int[] number,int low,int high) {
if(low<high){//to identify whether this part has more than 1 numbers
int pivotloc=Partition(number,low,high);
quickSort(number,low,pivotloc-1);
quickSort(number,pivotloc+1,high);
}
}
//Partition算法10.6（b）
static int Partition(int[] number,int low,int high){
int tempt=number[low];
int pivotkey=number[low];
while(low<high){
while(low<high && number[high]>=pivotkey)
high--;
number[low]=number[high];
while(low<high && number[low]<=pivotkey)
low++;
number[high]=number[low];
}
number[low]=tempt;
return low;
}
}

```

Sort

• 0

开心

• 0

板砖

• 0

感动

• 0

有用

• 0

疑问

• 0

难过

• 0

无聊

• 0

震惊

1 sort
3 Sort
4 sort
5 Sort
6 sort
7 Sort
8 sort
9 sort
10 sort
11 sort
12 sort
13 Sort
14 Sort
15 Sort
16 sort
17 sort
18 sort()
19 sort
20 sort

1 SORT

1. Merge Sort and Quick Sort are two classic sorting algorithms and Critical components in th
dic = {'a':31, 'bc':5, 'c':3, 'asd':4, '33':56, 'd':0} 想把dic的value按照从大到小排序（value

Sort List 问题： Sort a linked list in O(n log n) time using constant space complexity. 思路
1. Basic plan: a) Shuffle the array. b) Partition so that, for some j – entry a[j] is in pla
1. Quicksort is honored as one of top 10 algorithms of 20th century in science and engineerin