1 2 3 4 5 6 7 8 9 10 11 12 13
package fit
//Item interface has to be implemented by the items which should be packed.
type Item interface {
Size() int64
}
//ItemsBySize implements sort.Interface
type ItemsBySize []Item
func (x ItemsBySize) Len() int { return len(x) }
func (x ItemsBySize) Less(i, j int) bool { return x[i].Size() < x[j].Size() }
func (x ItemsBySize) Swap(i, j int) { x[i], x[j] = x[j], x[i] }