1 package blockchain
2 3 // timeSorter implements sort.Interface to allow a slice of timestamps to be sorted.
4 type timeSorter []int64
5 6 // Len returns the number of timestamps in the slice. It is part of the sort.Interface implementation.
7 func (s timeSorter) Len() int {
8 return len(s)
9 }
10 11 // Swap swaps the timestamps at the passed indices. It is part of the sort.Interface implementation.
12 func (s timeSorter) Swap(i, j int) {
13 s[i], s[j] = s[j], s[i]
14 }
15 16 // Less returns whether the timstamp with index i should txsort before the timestamp with index j. It is part of the
17 // sort.Interface implementation.
18 func (s timeSorter) Less(i, j int) bool {
19 return s[i] < s[j]
20 }
21