diff --git a/lib/util.js b/lib/util.js index d186e55..86cb589 100644 --- a/lib/util.js +++ b/lib/util.js @@ -54,6 +54,12 @@ function trimUselessPings(data) { for (var x = 0; x < listing.length; x++) { var entry = listing[x]; + // Make sure we're sorted, otherwise the smoothing code below can + // select wrongly get an older (and worse) ping before one with players online. + listing.sort(function(a, b) { + return a[0] - b[0]; + }); + // 0 is the index of the timestamp. // See the convertPingsToGraph method. if (entry[0] - lastTimestamp >= 60 * 1000) {