mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-09 22:30:47 +00:00
add byName, it implements sort.Sort interface
This commit is contained in:
parent
5a6947af2c
commit
d244a9cc35
@ -2,6 +2,18 @@ package one
|
|||||||
|
|
||||||
const noValue = -1
|
const noValue = -1
|
||||||
|
|
||||||
|
type byName []zWire
|
||||||
|
|
||||||
|
func (b byName) Len() int {
|
||||||
|
return len(b)
|
||||||
|
}
|
||||||
|
func (b byName) Less(i, j int) bool {
|
||||||
|
return b[j].name < b[i].name
|
||||||
|
}
|
||||||
|
func (b byName) Swap(i, j int) {
|
||||||
|
b[i], b[j] = b[j], b[i]
|
||||||
|
}
|
||||||
|
|
||||||
type zWire struct {
|
type zWire struct {
|
||||||
name string
|
name string
|
||||||
value int
|
value int
|
||||||
|
Loading…
Reference in New Issue
Block a user