Skip to content

Commit

Permalink
add second key to sorting in console
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Jan 31, 2019
1 parent 9d2e6ea commit 2183d39
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,13 @@ func (c *Console) updateLoop(g *gocui.Gui) {
func (c *Console) updateTorrents(g *gocui.Gui) {
torrents, err := c.client.ListTorrents()

sort.Slice(torrents, func(i, j int) bool { return torrents[i].CreatedAt.Time.Before(torrents[j].CreatedAt.Time) })
sort.Slice(torrents, func(i, j int) bool {
a, b := torrents[i], torrents[j]
if a.CreatedAt.Equal(b.CreatedAt.Time) {
return a.ID < b.ID
}
return a.CreatedAt.Time.Before(b.CreatedAt.Time)
})

c.m.Lock()
c.torrents = torrents
Expand Down

0 comments on commit 2183d39

Please sign in to comment.