summaryrefslogtreecommitdiff
path: root/compare.go
diff options
context:
space:
mode:
authorKurt Jung <kurt.w.jung@gmail.com>2015-10-10 15:24:43 -0400
committerKurt Jung <kurt.w.jung@gmail.com>2015-10-10 15:24:43 -0400
commit92858a8b5ff04e4196597d9d517f3b2a0d651579 (patch)
tree4697ba0ba2019cd48d29ad462da280bd18aa6e36 /compare.go
parent5847afd8a205853a7effbf749b7a388ae325eb24 (diff)
Conditionally sort image catalog. Correct small typos.
Diffstat (limited to 'compare.go')
-rw-r--r--compare.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/compare.go b/compare.go
index 3fd7eaf..64cad1f 100644
--- a/compare.go
+++ b/compare.go
@@ -21,8 +21,31 @@ import (
"fmt"
"io"
"io/ioutil"
+ "sort"
)
+type sortType struct {
+ length int
+ less func(int, int) bool
+ swap func(int, int)
+}
+
+func (s *sortType) Len() int {
+ return s.length
+}
+
+func (s *sortType) Less(i, j int) bool {
+ return s.less(i, j)
+}
+
+func (s *sortType) Swap(i, j int) {
+ s.swap(i, j)
+}
+
+func gensort(Len int, Less func(int, int) bool, Swap func(int, int)) {
+ sort.Sort(&sortType{length: Len, less: Less, swap: Swap})
+}
+
func writeBytes(leadStr string, startPos int, sl []byte) {
var pos, max int
var b byte