diff options
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 |