From 5b0c52d21dae39f30442c2b9d986fd40e9dfb5f0 Mon Sep 17 00:00:00 2001 From: K K Date: Thu, 24 Jun 2021 00:05:40 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E9=80=86=E9=A0=86=EF=BC=8B=E9=A0=86?= =?UTF-8?q?=E4=BD=8D=E4=BB=98=E3=81=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index ff2e98b9..f0b53db8 100644 --- a/app.js +++ b/app.js @@ -32,10 +32,10 @@ rl.on('close', () => { value.change = value.popu15 / value.popu10; } const rankingArray = Array.from(prefectureDataMap).sort((pair1, pair2) => { - return pair2[1].change - pair1[1].change; + return pair1[1].change - pair2[1].change; }); - const rankingStrings = rankingArray.map(([key, value]) => { - return key + ': ' + value.popu10 + '=>' + value.popu15 + ' 変化率:' + value.change; + const rankingStrings = rankingArray.map(([key, value],i) => { + return i+'位'+key + ': ' + value.popu10 + '=>' + value.popu15 + ' 変化率:' + value.change; }); console.log(rankingStrings); }); \ No newline at end of file From 5bf387579bc19a48f46c92bfee4cda59c36a35fb Mon Sep 17 00:00:00 2001 From: K K Date: Thu, 24 Jun 2021 00:08:33 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E9=80=86=E9=A0=86=EF=BC=8B=E9=A0=86?= =?UTF-8?q?=E4=BD=8D=E4=BB=98=E3=81=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index f0b53db8..28daefd9 100644 --- a/app.js +++ b/app.js @@ -35,7 +35,7 @@ rl.on('close', () => { return pair1[1].change - pair2[1].change; }); const rankingStrings = rankingArray.map(([key, value],i) => { - return i+'位'+key + ': ' + value.popu10 + '=>' + value.popu15 + ' 変化率:' + value.change; + return (i+1)+'位'+key + ': ' + value.popu10 + '=>' + value.popu15 + ' 変化率:' + value.change; }); console.log(rankingStrings); }); \ No newline at end of file