From dbb453ad55f383339a707f9974573662dadf73f9 Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Sat, 4 Sep 2021 03:15:19 +0300 Subject: [PATCH] Improve team and reviewer sorting --- src/paths/index/components/prs/PullRequestItem.js | 9 ++++++--- src/paths/index/entry.js | 14 ++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/paths/index/components/prs/PullRequestItem.js b/src/paths/index/components/prs/PullRequestItem.js index bb911ac..c4756a6 100644 --- a/src/paths/index/components/prs/PullRequestItem.js +++ b/src/paths/index/components/prs/PullRequestItem.js @@ -228,9 +228,12 @@ export default class PullRequestItem extends LitElement { const other_teams = [].concat(this.teams); other_teams.sort((a, b) => { - if (a > b) return 1; - if (a < b) return -1; - return 0; + const a_name = a.toLowerCase().replace(/^_/, ""); + const b_name = b.toLowerCase().replace(/^_/, ""); + + if (a_name > b_name) return 1; + if (a_name < b_name) return -1; + return 0; }); const authorClassList = [ "pr-author-value" ]; diff --git a/src/paths/index/entry.js b/src/paths/index/entry.js index 60f7712..d923b77 100644 --- a/src/paths/index/entry.js +++ b/src/paths/index/entry.js @@ -73,15 +73,21 @@ export default class EntryComponent extends LitElement { if (a.id === -1) return -1; if (b.id === -1) return -1; - if (a.name > b.name) return 1; - if (a.name < b.name) return -1; + const a_name = a.name.toLowerCase().replace(/^_/, ""); + const b_name = b.name.toLowerCase().replace(/^_/, ""); + + if (a_name > b_name) return 1; + if (a_name < b_name) return -1; return 0; }); this._orderedReviewers = Object.values(this._reviewers); this._orderedReviewers.sort((a, b) => { - if (a.name > b.name) return 1; - if (a.name < b.name) return -1; + const a_name = a.name.toLowerCase(); + const b_name = b.name.toLowerCase(); + + if (a_name > b_name) return 1; + if (a_name < b_name) return -1; return 0; });