github.com/blend/go-sdk@v1.20220411.3/timeutil/descending.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - 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  // Descending sorts a given list of times ascending, or min to max.
    20  type Descending []time.Time
    21  
    22  // Len implements sort.Sorter
    23  func (d Descending) Len() int { return len(d) }
    24  
    25  // Swap implements sort.Sorter
    26  func (d Descending) Swap(i, j int) { d[i], d[j] = d[j], d[i] }
    27  
    28  // Less implements sort.Sorter
    29  func (d Descending) Less(i, j int) bool { return d[i].After(d[j]) }