Created
February 19, 2020 23:50
-
-
Save stephenwithav/90c93edf9d9a4f144be34aee3244b50f to your computer and use it in GitHub Desktop.
sort.Interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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