Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.

Commit 44afd8b

Browse files
committed
better sorting
On-behalf-of: @SAP [email protected] Signed-off-by: Artem Shcherbatiuk <[email protected]>
1 parent 0787ae7 commit 44afd8b

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

listener/pkg/apischema/builder.go

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -261,31 +261,16 @@ func (b *SchemaBuilder) buildKindRegistry() {
261261
// Ensure deterministic order for picks: sort each slice by Group, Version, Kind, SchemaKey
262262
for kindKey, infos := range b.kindRegistry {
263263
slices.SortFunc(infos, func(a, b ResourceInfo) int {
264-
if a.Group != b.Group {
265-
if a.Group < b.Group {
266-
return -1
267-
}
268-
return 1
264+
if cmp := strings.Compare(a.Group, b.Group); cmp != 0 {
265+
return cmp
269266
}
270-
if a.Version != b.Version {
271-
if a.Version < b.Version {
272-
return -1
273-
}
274-
return 1
267+
if cmp := strings.Compare(a.Version, b.Version); cmp != 0 {
268+
return cmp
275269
}
276-
if a.Kind != b.Kind {
277-
if a.Kind < b.Kind {
278-
return -1
279-
}
280-
return 1
270+
if cmp := strings.Compare(a.Kind, b.Kind); cmp != 0 {
271+
return cmp
281272
}
282-
if a.SchemaKey < b.SchemaKey {
283-
return -1
284-
}
285-
if a.SchemaKey > b.SchemaKey {
286-
return 1
287-
}
288-
return 0
273+
return strings.Compare(a.SchemaKey, b.SchemaKey)
289274
})
290275
b.kindRegistry[kindKey] = infos
291276
}

0 commit comments

Comments
 (0)