From 353a66b079b0091f3ca4a74cd89f52b2f0bd6029 Mon Sep 17 00:00:00 2001 From: rigormorrtiss Date: Tue, 3 Aug 2021 12:54:12 +0400 Subject: [PATCH] Sort channels on guild and channel selected --- discordo.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/discordo.go b/discordo.go index 7ec7338..7ff0070 100644 --- a/discordo.go +++ b/discordo.go @@ -158,7 +158,7 @@ func onGuildsDropDownSelected(_ string, i int) { return } - sort.Slice(channels, func(i, j int) bool { + sort.SliceStable(channels, func(i, j int) bool { return channels[i].Position < channels[j].Position }) @@ -196,6 +196,10 @@ func onChannelsTreeViewSelected(node *tview.TreeNode) { return } + sort.SliceStable(channels, func(i, j int) bool { + return channels[i].Position < channels[j].Position + }) + for i := range channels { channel := channels[i] if (channel.Type == discord.GuildText || channel.Type == discord.GuildNews) && channel.CategoryID == currentChannel.ID {