From d244a9cc35007ad37275ef0b63310fb33aba7548 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 26 Dec 2024 13:11:44 +0000 Subject: [PATCH] add byName, it implements sort.Sort interface --- day-24/internal/one/zwire.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/day-24/internal/one/zwire.go b/day-24/internal/one/zwire.go index 1868519..bbdc6e2 100644 --- a/day-24/internal/one/zwire.go +++ b/day-24/internal/one/zwire.go @@ -2,6 +2,18 @@ package one 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 { name string value int