Skip to content

Instantly share code, notes, and snippets.

@stephenwithav
Created February 19, 2020 23:50
Show Gist options
  • Save stephenwithav/90c93edf9d9a4f144be34aee3244b50f to your computer and use it in GitHub Desktop.
Save stephenwithav/90c93edf9d9a4f144be34aee3244b50f to your computer and use it in GitHub Desktop.
sort.Interface
# name: Sort interface template
# key: tsort
# --
type $1 []$2
func ($3 $1) Len() int { return len($3) }
func ($3 $1) Less(i, j int) bool { return $3[i] < $3[j] }
func ($3 $1) Swap(i, j int) { $3[i], $3[j] = $3[j], $3[i] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment