Skip to content

Instantly share code, notes, and snippets.

@Qs-F
Created August 27, 2020 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Qs-F/d2fb1bf6e622c92cad8424abc128adc4 to your computer and use it in GitHub Desktop.
Save Qs-F/d2fb1bf6e622c92cad8424abc128adc4 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"sort"
)
func main() {
s := []int{2, 1, 3, 4}
sort.SliceStable(s, func(i, j int) bool {
// return false // as it is
// return true // reversed
})
fmt.Println(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment