aboutsummaryrefslogtreecommitdiff
path: root/dbstore
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-03-18 21:54:53 -0400
committerPaul Duncan <pabs@pablotron.org>2022-03-18 21:54:53 -0400
commitdc0be0efa4b2320f5859a9df33de2f67199d69ef (patch)
tree4002ecf62b6a588b26d5f27d3382f282f707327a /dbstore
parent3b148c9358a76bd7eabde4c8333f5c31fb1fb581 (diff)
downloadcvez-dc0be0efa4b2320f5859a9df33de2f67199d69ef.tar.bz2
cvez-dc0be0efa4b2320f5859a9df33de2f67199d69ef.zip
dbstore/cisasearchrow.go: add byRank sort.Interface
Diffstat (limited to 'dbstore')
-rw-r--r--dbstore/cisasearchrow.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/dbstore/cisasearchrow.go b/dbstore/cisasearchrow.go
index 9c90eee..19dd04c 100644
--- a/dbstore/cisasearchrow.go
+++ b/dbstore/cisasearchrow.go
@@ -19,3 +19,21 @@ type CisaSearchRow struct {
DueAt rfc3339.Date `json:"due_at"` // Date due
Rank float32 `json:"rank"` // search result rank
}
+
+// sort.Interface for CisaSearchRow slice, sorted by rank.
+type byRank []CisaSearchRow
+
+// Required by sort.Interface.
+func (r byRank) Len() int {
+ return len(r)
+}
+
+// Required by sort.Interface.
+func (r byRank) Less(i, j int) bool {
+ return r[i].Rank < r[j].Rank
+}
+
+// Required by sort.Interface.
+func (r byRank) Swap(i, j int) {
+ r[i], r[j] = r[j], r[i]
+}