From aa1159888fa9be9eca54f002e841019d7e6c0de7 Mon Sep 17 00:00:00 2001 From: Bauke Date: Sun, 24 Jun 2018 23:52:55 +0200 Subject: [PATCH] Add label sorting alphabetically --- main.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main.js b/main.js index d9295d4..ee98d6f 100644 --- a/main.js +++ b/main.js @@ -199,9 +199,12 @@ function createStatistics() { } } - statistics += 'Total amount of labels assigned to currently open issues:\n' + let labelsOrdered = {} + Object.keys(labels).sort().forEach(label => labelsOrdered[label] = labels[label]) - for (const label in labels) { + statistics += 'Total amount of labels assigned to currently open issues:\n\n' + + for (const label in labelsOrdered) { statistics += `* [${label}](https://gitlab.com/tildes/tildes/issues?state=opened&label_name%5B%5D=${label.replace(' ', '+')}): ${labels[label]} times.\n` } @@ -214,9 +217,12 @@ function createStatistics() { } } - statistics += '\nTotal amount of labels assigned to closed issues:\n' + labelsOrdered = {} + Object.keys(labels).sort().forEach(label => labelsOrdered[label] = labels[label]) - for (const label in labels) { + statistics += '\nTotal amount of labels assigned to closed issues:\n\n' + + for (const label in labelsOrdered) { statistics += `* [${label}](https://gitlab.com/tildes/tildes/issues?state=closed&label_name%5B%5D=${label.replace(' ', '+')}): ${labels[label]} times.\n` }