mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-10 14:50:46 +00:00
21 lines
281 B
Go
21 lines
281 B
Go
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
|
|
})
|
|
}
|