func main() {
nums := []int{49, 38, 65, 97, 76, 13, 27, 49}
quickSort(nums, 0, len(nums)-1)
fmt.Printf("%v\n", nums)
}
func quickSort(nums []int, low int, high int) {
if low < high {
pivotloc := partition(nums, low, high)
quickSort(nums, low, pivotloc-1)
quickSort(nums, pivotloc+1, high)
}
}
func partition(nums []int, low int, high int) int {
pivotkey := nums[low]
for low < high {
for low < high && nums[high] >= pivotkey {
high--
}
nums[low] = nums[high]
for low < high && nums[low] <= pivotkey {
low++
}
nums[high] = nums[low]
}
nums[low] = pivotkey
return low
}