use intArray or strArray to define []int or []string.
intArray
strArray
[]int
[]string
You can use them simply like this:
x := intArray {1,2,3,1} QuickSort(x, 0, x.Len()-1) y := strArray {'hello', 'go', 'algorithms'} QuickSort(y, 0, y.Len()-1)
Both intArray and strArray implements interface Ord
interface Ord
type Ord interface { Swap(i, j int) Less(i,j int) bool Len() int }
You can implements Ord interface to make your own type sortable.
Ord
About 700ms for sort 1,000,000 random number
[quick sort wiki]
There was an error while loading. Please reload this page.