From 9f989c2d894131808c0a10e4265a285782b00906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20LEBLOND?= Date: Wed, 22 Jan 2025 10:52:39 +0100 Subject: [PATCH] Sort orgs by name --- gristtools/gristtools.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gristtools/gristtools.go b/gristtools/gristtools.go index 78ea656..f29c235 100644 --- a/gristtools/gristtools.go +++ b/gristtools/gristtools.go @@ -319,7 +319,12 @@ func DisplayDoc(docId string) { // Displays the list of accessible organizations func DisplayOrgs() { + // Getting the list of organizations lstOrgs := gristapi.GetOrgs() + // Sorting the list of organizations by name (lowercase) + sort.Slice(lstOrgs, func(i, j int) bool { + return strings.ToLower(lstOrgs[i].Name) < strings.ToLower(lstOrgs[j].Name) + }) table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{"Id", "Name"}) for _, org := range lstOrgs {