From 0efe3eef4aa01c09816912bbb6bb7ee337a07770 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Thu, 10 Sep 2015 14:04:59 -0400 Subject: [PATCH] Sort threads by ID --- terminal/command.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/terminal/command.go b/terminal/command.go index 09e3d003..26f1c24a 100644 --- a/terminal/command.go +++ b/terminal/command.go @@ -153,6 +153,12 @@ func (c *Commands) help(client service.Client, args ...string) error { return w.Flush() } +type byID []*api.Thread + +func (a byID) Len() int { return len(a) } +func (a byID) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a byID) Less(i, j int) bool { return a[i].ID < a[j].ID } + func threads(client service.Client, args ...string) error { threads, err := client.ListThreads() if err != nil { @@ -162,6 +168,7 @@ func threads(client service.Client, args ...string) error { if err != nil { return err } + sort.Sort(byID(threads)) for _, th := range threads { prefix := " " if state.CurrentThread != nil && state.CurrentThread.ID == th.ID {