import (
"fmt"
"github.com/chasestarr/quicksort"
)
// implements same interface as Go's 'sort' package
type sortable []int
func (s sortable) Less(i, j int) bool { return s[i] < s[j] }
func (s sortable) Len() int { return len(s) }
func (s sortable) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func main() {
input := []int{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
quicksort.Sort(sortable(input))
fmt.Println(input) // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}-
Notifications
You must be signed in to change notification settings - Fork 0
chasestarr/quicksort
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
Quicksort algorithm, implements same interface as Go's 'sort' package
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published