(i, j int)
| 34 | func (s *sorterZCount) Len() int { return len(s.order) } |
| 35 | func (s *sorterZCount) Swap(i, j int) { s.order[i], s.order[j] = s.order[j], s.order[i] } |
| 36 | func (s *sorterZCount) Less(i, j int) bool { |
| 37 | vi := int64(s.get(s.order[i])) |
| 38 | vj := int64(s.get(s.order[j])) |
| 39 | return bit.Count(bit.ZEncode(vi)) < bit.Count(bit.ZEncode(vj)) |
| 40 | } |
| 41 | |
| 42 | func SortByZCount(items []int, get func(i int) int) { |
| 43 | sort.Sort(&sorterZCount{ |