From 0b70658cd379943fe7545a4bb1c1b044178a32c9 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Tue, 16 Aug 2016 13:12:52 -0700 Subject: [PATCH] Unpacked parameters are now sorted --- lib/device.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/device.js b/lib/device.js index 9e05bd4..ba2c2af 100644 --- a/lib/device.js +++ b/lib/device.js @@ -199,6 +199,26 @@ function unpack(deviceData, path, revision) { } } + allMatches.sort(function(a, b) { + for (let i = 0; i < a.length; ++ i) { + if (a === b) + continue; + + // Use numeric sorting for numbers + let ia = parseInt(a), ib = parseInt(b); + if (ia.toString() == a && ib.toString() == b) { + a = ia; + b = ib; + } + + if (a < b) + return -1; + else + return 1; + } + return 0; + }); + return allMatches; }