From 8609aef653b209e6c8a291771b6dcb8db30b5fc1 Mon Sep 17 00:00:00 2001 From: Melissa Date: Tue, 13 Sep 2022 14:24:59 -0600 Subject: [PATCH] sort group fields alphabetically --- .../explain_log_rate_spikes_analysis.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/aiops/public/components/explain_log_rate_spikes/explain_log_rate_spikes_analysis.tsx b/x-pack/plugins/aiops/public/components/explain_log_rate_spikes/explain_log_rate_spikes_analysis.tsx index 0aece599729f0..f278a7f8b5908 100644 --- a/x-pack/plugins/aiops/public/components/explain_log_rate_spikes/explain_log_rate_spikes_analysis.tsx +++ b/x-pack/plugins/aiops/public/components/explain_log_rate_spikes/explain_log_rate_spikes_analysis.tsx @@ -147,10 +147,11 @@ export const ExplainLogRateSpikesAnalysis: FC }, {} as Record>); const tableItems = mockData.map(({ group, docCount }, index) => { + const sortedGroup = group.sort((a, b) => (a.field > b.field) ? 1 : ((b.field > a.field) ? -1 : 0)); const dedupedGroup = {}; const repeatedValues = {}; - group.forEach((pair) => { + sortedGroup.forEach((pair) => { const fieldName = pair.field; const fieldValue = pair.value; if (groupFieldValuesCountMap[fieldName][fieldValue] <= 2) {