func (s *argsSorter) Less(i, j int) bool {
	return s.by(s.args[i], s.args[j])
}
Less implements sort.Sort interface.
package bus
import (
	"sort"
	"sync"
	"github.com/prometheus/prometheus/storage/remote"
)
const MOCKWRITEERR = `WRITEERR`
type MockWriteArgs struct {
	Key          string
	WriteRequest *remote.WriteRequest
}
type MockWriter struct {
	WErr       error
	WriteCount int
	Args       []*MockWriteArgs
	mutex      *sync.Mutex
}
func NewMockWriter() *MockWriter {
	return &MockWriter{
		Args:  make([]*MockWriteArgs, 0),
		mutex: new(sync.Mutex),
	}
}
func (w *MockWriter) Write(k string, wr *remote.WriteRequest) error {
	w.mutex.Lock()
	w.Args = append(w.Args, &MockWriteArgs{Key: k, WriteRequest: wr})
	w.mutex.Unlock()
	if w.WErr == nil {
		*(&w.WriteCount)++
		return nil
	}
	return w.WErr
}
type argsSorter struct {
	args []*MockWriteArgs
	by   func(a1, a2 *MockWriteArgs) bool
}
func (s *argsSorter) Len() int { return len(s.args) }
func (s *argsSorter) Swap(i, j int) {
	s.args[i], s.args[j] = s.args[j], s.args[i]
}