diff options
author | Kurt Jung <kurt.w.jung@gmail.com> | 2015-10-10 15:24:43 -0400 |
---|---|---|
committer | Kurt Jung <kurt.w.jung@gmail.com> | 2015-10-10 15:24:43 -0400 |
commit | 92858a8b5ff04e4196597d9d517f3b2a0d651579 (patch) | |
tree | 4697ba0ba2019cd48d29ad462da280bd18aa6e36 /compare.go | |
parent | 5847afd8a205853a7effbf749b7a388ae325eb24 (diff) |
Conditionally sort image catalog. Correct small typos.
Diffstat (limited to 'compare.go')
-rw-r--r-- | compare.go | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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 |