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 }) }