aboutsummaryrefslogtreecommitdiff
path: root/dbstore
diff options
context:
space:
mode:
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]
+}