Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-cidutil
Commits
60d67ce4
Unverified
Commit
60d67ce4
authored
Sep 24, 2018
by
Steven Allen
Committed by
GitHub
Sep 24, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5 from ipfs/fix/cid-slice
add a utility method for sorting CID slices
parents
6c3d0c5a
e23b8609
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
slice.go
slice.go
+30
-0
No files found.
slice.go
0 → 100644
View file @
60d67ce4
package
cidutil
import
(
"github.com/ipfs/go-cid"
"sort"
)
// Slice is a convenience type for sorting CIDs
type
Slice
[]
cid
.
Cid
func
(
s
Slice
)
Len
()
int
{
return
len
(
s
)
}
func
(
s
Slice
)
Less
(
i
,
j
int
)
bool
{
return
s
[
i
]
.
KeyString
()
<
s
[
j
]
.
KeyString
()
}
func
(
s
Slice
)
Swap
(
i
,
j
int
)
{
s
[
i
],
s
[
j
]
=
s
[
j
],
s
[
i
]
}
func
(
s
Slice
)
Sort
()
{
sort
.
Sort
(
s
)
}
// Sort sorts a slice of CIDs
func
Sort
(
s
[]
cid
.
Cid
)
{
Slice
(
s
)
.
Sort
()
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment