github.com/blend/go-sdk@v1.20240719.1/timeutil/ascending.go (about) 1 /* 2 3 Copyright (c) 2024 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package timeutil 9 10 import ( 11 "sort" 12 "time" 13 ) 14 15 var ( 16 _ sort.Interface = (*Ascending)(nil) 17 ) 18 19 // Ascending sorts a given list of times ascending, or min to max. 20 type Ascending []time.Time 21 22 // Len implements sort.Sorter 23 func (a Ascending) Len() int { return len(a) } 24 25 // Swap implements sort.Sorter 26 func (a Ascending) Swap(i, j int) { a[i], a[j] = a[j], a[i] } 27 28 // Less implements sort.Sorter 29 func (a Ascending) Less(i, j int) bool { return a[i].Before(a[j]) }