From 92858a8b5ff04e4196597d9d517f3b2a0d651579 Mon Sep 17 00:00:00 2001 From: Kurt Jung Date: Sat, 10 Oct 2015 15:24:43 -0400 Subject: Conditionally sort image catalog. Correct small typos. --- compare.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'compare.go') 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 -- cgit v1.2.1-24-ge1ad