We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0e1a8db commit 0563979Copy full SHA for 0563979
slice.go
@@ -0,0 +1,30 @@
1
+package cidutil
2
+
3
+import (
4
+ "github.com/ipfs/go-cid"
5
+ "sort"
6
+)
7
8
+// Slice is a convenience type for sorting CIDs
9
+type Slice []cid.Cid
10
11
+func (s Slice) Len() int {
12
+ return len(s)
13
+}
14
15
+func (s Slice) Less(i, j int) bool {
16
+ return s[i].KeyString() < s[j].KeyString()
17
18
19
+func (s Slice) Swap(i, j int) {
20
+ s[i], s[j] = s[j], s[i]
21
22
23
+func (s Slice) Sort() {
24
+ sort.Sort(s)
25
26
27
+// Sort sorts a slice of CIDs
28
+func Sort(s []cid.Cid) {
29
+ Slice(s).Sort()
30
0 commit comments