Skip to content

Commit 09ed8fd

Browse files
committed
sort
1 parent e6bd6cb commit 09ed8fd

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

coderd/database/db2sdk/db2sdk.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"net/url"
8+
"sort"
89
"strconv"
910
"strings"
1011
"time"
@@ -414,6 +415,16 @@ func AppSubdomain(dbApp database.WorkspaceApp, agentName, workspaceName, ownerNa
414415
}
415416

416417
func Apps(dbApps []database.WorkspaceApp, agent database.WorkspaceAgent, ownerName string, workspace database.Workspace) []codersdk.WorkspaceApp {
418+
sort.Slice(dbApps, func(i, j int) bool {
419+
if dbApps[i].DisplayOrder != dbApps[j].DisplayOrder {
420+
return dbApps[i].DisplayOrder < dbApps[j].DisplayOrder
421+
}
422+
if dbApps[i].DisplayName != dbApps[j].DisplayName {
423+
return dbApps[i].DisplayName < dbApps[j].DisplayName
424+
}
425+
return dbApps[i].Slug < dbApps[j].Slug
426+
})
427+
417428
apps := make([]codersdk.WorkspaceApp, 0)
418429
for _, dbApp := range dbApps {
419430
apps = append(apps, codersdk.WorkspaceApp{

coderd/database/dbmem/dbmem.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5826,6 +5826,7 @@ func (q *FakeQuerier) InsertWorkspaceApp(_ context.Context, arg database.InsertW
58265826
HealthcheckInterval: arg.HealthcheckInterval,
58275827
HealthcheckThreshold: arg.HealthcheckThreshold,
58285828
Health: arg.Health,
5829+
DisplayOrder: arg.DisplayOrder,
58295830
}
58305831
q.workspaceApps = append(q.workspaceApps, workspaceApp)
58315832
return workspaceApp, nil

0 commit comments

Comments
 (0)