This is a created article in which the information may have evolved or changed.
Package Mainimport ("FMT" "Math/rand" "Time") Func main () {var Z []intfor I: = 0; i < 1000000; i++ {z = append (z, Rand. INTN (100000))}sort (z)}func sort (list []int) {If Len (list) <= 1 {return//exit condition}i, J: = 0, Len (list) -1index: = 1//indicates first comparison The index location of the. Key: = List[0]//The reference value for the first comparison. Select the first number if LIST[INDEX] > key {list[i], list[j] = list[j], list[i]j--//To replace the position of the number with the end of the large value, Make the number greater than the reference value at the back of} else {list[i], list[index] = List[index], list[i]i++//represents taking a small value with the previous replacement position so that the number less than the reference value is in front index++}sort (list[:i]// Processing the array preceding the reference value sort (list[i+1:]) processing the arrays following the reference value}