From 139db8fb1313f09c343225ab8179136f6b7aff2d Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Mon, 20 Oct 2014 16:29:30 +0200 Subject: [PATCH] Fix for sort that broke graphs. A shadow-copy was made and sorted, now a deep-copy is made an sorted. The order of the original array is now no longer altered in the process of determining some statistical values. --- StatisticsCalculator.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/StatisticsCalculator.java b/StatisticsCalculator.java index 96d9de1..a4e3ee0 100644 --- a/StatisticsCalculator.java +++ b/StatisticsCalculator.java @@ -40,8 +40,15 @@ public class StatisticsCalculator { return avg; } - public static double median(ArrayList array){ - Collections.sort(array); //sort the array + public static double median(ArrayList array2){ + ArrayList array = new ArrayList(); + + for(double db : array2) + { + array.add(db); + } + + Collections.sort(array); //sort the array double median = 0; int middle = array.size()/2; //calculate the middle of the array