From 41ea9139c69ef0ed53192d3b579c22a99b9737a9 Mon Sep 17 00:00:00 2001 From: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> Date: Thu, 17 Aug 2023 15:13:31 +0200 Subject: [PATCH] Use simpler sort function --- .../metricAggregator/metricAggregatorFunctions.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/internal/metricAggregator/metricAggregatorFunctions.go b/internal/metricAggregator/metricAggregatorFunctions.go index 2aea1ae..83eeb6c 100644 --- a/internal/metricAggregator/metricAggregatorFunctions.go +++ b/internal/metricAggregator/metricAggregatorFunctions.go @@ -128,18 +128,7 @@ func medianAnyType[T float64 | float32 | int | int32 | int64](values []T) (T, er if len(values) == 0 { return 0.0, errors.New("median function requires at least one argument") } - slices.SortFunc( - values, - func(a T, b T) int { - if a < b { - return -1 - } else if a > b { - return 1 - } else { - return 0 - } - }, - ) + slices.Sort(values) var median T if midPoint := len(values) % 2; midPoint == 0 { median = (values[midPoint-1] + values[midPoint]) / 2