快排思想可以看这里:快速排序思想
清晰易懂
package main
import "fmt"
func sort_quick(source *[]int,low int, height int){
if low >= height{
return
}
base := (*source)[low]
first := low
end := height
for low < height{
for low < height && base <= (*source)[height] {
height --
}
for low < height && base >= (*source)[low] {
low ++
}
(*source)[low],(*source)[height] = (*source)[height],(*source)[low]
}
(*source)[first],(*source)[height] = (*source)[height],(*source)[first]
sort_quick(source,first,low)
sort_quick(source,low+1,end)
}
func main() {
var source = []int{4,3,2,5,1,7,8,9,0,11,23,45,12,10,13,13,13}
sort_quick(&source,0,len(source)-1)
fmt.Println(source)
}```