From e715816556375239966d4a932c58d6c97d3a98bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Tue, 23 Jun 2020 16:57:32 +0100 Subject: [PATCH] fix(api): ensure stable sort order when group is repeated --- cmd/karma/alerts.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/karma/alerts.go b/cmd/karma/alerts.go index 05722b1b5..c8034c264 100644 --- a/cmd/karma/alerts.go +++ b/cmd/karma/alerts.go @@ -157,6 +157,9 @@ func getGroupLabel(group *models.APIAlertGroup, label string) string { } func sortByStartsAt(i, j int, groups []models.APIAlertGroup, sortReverse bool) bool { + if groups[i].LatestStartsAt == groups[j].LatestStartsAt { + return groups[i].ID > groups[j].ID + } if sortReverse { return groups[i].LatestStartsAt.After(groups[j].LatestStartsAt) }