From 16344080601a0f953e7d1dc91cd83631405aa986 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Wed, 26 Jul 2023 13:57:09 +0800 Subject: [PATCH] Build stable reject domainsets --- Build/build-reject-domainset.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Build/build-reject-domainset.js b/Build/build-reject-domainset.js index 65459798..69ef987b 100644 --- a/Build/build-reject-domainset.js +++ b/Build/build-reject-domainset.js @@ -208,6 +208,12 @@ const domainSuffixSet = new Set(); if (a.domain < b.domain) { return -1; } + if (a.v > b.v) { + return 1; + } + if (a.v < b.v) { + return -1; + } return 0; }; const sortedDomainSets = dudupedDominArray @@ -242,7 +248,13 @@ const domainSuffixSet = new Set(); await fs.promises.writeFile( pathResolve(__dirname, '../List/internal/reject-stats.txt'), Object.entries(rejectDomainsStats) - .sort((a, b) => b[1] - a[1]) + .sort((a, b) => { + const t = b[1] - a[1]; + if (t === 0) { + return a[0].localeCompare(b[0]); + } + return t; + }) .map(([domain, count]) => `${domain}${' '.repeat(100 - domain.length)}${count}`) .join('\n') );