1// Copyright (c) 2013-2017 The btcsuite developers
2// Use of this source code is governed by an ISC
3// license that can be found in the LICENSE file.
4
5package blockchain
6
7// timeSorter implements sort.Interface to allow a slice of timestamps to
8// be sorted.
9type timeSorter []int64
10
11// Len returns the number of timestamps in the slice.  It is part of the
12// sort.Interface implementation.
13func (s timeSorter) Len() int {
14	return len(s)
15}
16
17// Swap swaps the timestamps at the passed indices.  It is part of the
18// sort.Interface implementation.
19func (s timeSorter) Swap(i, j int) {
20	s[i], s[j] = s[j], s[i]
21}
22
23// Less returns whether the timstamp with index i should sort before the
24// timestamp with index j.  It is part of the sort.Interface implementation.
25func (s timeSorter) Less(i, j int) bool {
26	return s[i] < s[j]
27}
28