From 96aad3d5791d7a0330708041a060ad3783a002ec Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 26 May 2014 13:41:24 -0400 Subject: [PATCH] Pretty-print matchers with keys in sorted order --- route.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/route.js b/route.js index 3691821..f670d70 100644 --- a/route.js +++ b/route.js @@ -78,6 +78,13 @@ function Routing(exports) { return key in this.entries; }; + $Dict.prototype.sortedKeys = function () { + var ks = []; + for (var k in this.entries) ks.push(k); + ks.sort(); + return ks; + } + function is_emptyMatcher(m) { return (m === emptyMatcher); } @@ -1032,7 +1039,9 @@ function Routing(exports) { } var needSep = false; - for (var key in m.entries) { + var keys = m.sortedKeys(); + for (var keyi = 0; keyi < keys.length; keyi++) { + var key = keys[keyi]; var k = m.entries[key]; if (needSep) { acc.push("\n");