aoc2024/day-05/internal/update/update.go

21 lines
281 B
Go
Raw Normal View History

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