From 2183d3950829655535c6020bf0e106e5b66c76b5 Mon Sep 17 00:00:00 2001 From: Cenk Alti Date: Thu, 31 Jan 2019 22:46:54 +0300 Subject: [PATCH] add second key to sorting in console --- internal/console/console.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/console/console.go b/internal/console/console.go index 00bcff90..a80e89df 100644 --- a/internal/console/console.go +++ b/internal/console/console.go @@ -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