implement using custom sort function on an update struct

rerun benchmarks
This commit is contained in:
2024-12-09 01:05:54 +00:00
parent 965e704d39
commit 6b7f79b6f0
7 changed files with 85 additions and 111 deletions

View File

@@ -0,0 +1,20 @@
package update
import "slices"
type Update struct {
Pages []int
}
func (u Update) Sort(orderings map[int][]int) {
slices.SortFunc(u.Pages, func(p, q int) int {
v, ok := orderings[p]
if ok {
if slices.Contains(v, q) {
return -1
}
return 1
}
return 1
})
}