快速排序
排序
http://www.nowcoder.com/questionTerminal/2baf799ea0594abd974d37139de27896
func MySort( arr []int ) []int {
quickSort(arr, 0, len(arr)-1)
return arr
}
func quickSort(arr []int, start, end int){
i, j := start, end
key := arr[(start+end)/2]
for i <= j{
for arr[i] < key{
i++
}
for arr[j] > key{
j--
}
if i<=j{
arr[i],arr[j] = arr[j],arr[i]
i++
j--
}
}
if start < j{
quickSort(arr, start, j)
}
if end > i{
quickSort(arr, i, end)
}
}