Skip to content

Commit 154d2b4

Browse files
committed
presort templates
1 parent 39fc586 commit 154d2b4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cli/workspacecreate.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func workspaceCreate() *cobra.Command {
6767
return err
6868
}
6969

70+
slices.SortFunc(templates, func(a, b codersdk.Template) bool {
71+
return a.WorkspaceOwnerCount > b.WorkspaceOwnerCount
72+
})
73+
7074
templateNames := make([]string, 0, len(templates))
7175
templateByName := make(map[string]codersdk.Template, len(templates))
7276

@@ -85,9 +89,6 @@ func workspaceCreate() *cobra.Command {
8589
templateNames = append(templateNames, templateName)
8690
templateByName[templateName] = template
8791
}
88-
slices.SortFunc(templateNames, func(a, b string) bool {
89-
return templateByName[a].WorkspaceOwnerCount > templateByName[b].WorkspaceOwnerCount
90-
})
9192

9293
// Move the cursor up a single line for nicer display!
9394
option, err := cliui.Select(cmd, cliui.SelectOptions{

0 commit comments

Comments
 (0)