Skip to content

Commit

Permalink
use toLowerCase for comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
OnkarRuikar committed Sep 29, 2024
1 parent f6827ca commit ece8485
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions scripts/sort_and_unique_file_lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ if (!fs.existsSync(filePath)) {
process.exit(1);
}

function equalsIgnoreCase(string1, string2) {
return new RegExp(`^${string1}$`, "gi").test(string2);
}

const equalsIgnoreCase = (a, b) => a?.toLowerCase() === b?.toLowerCase();
const uniq = [];
const content = fs.readFileSync(filePath, "utf-8");
const lines = content.split("\n").sort((a, b) => {
a = a.toUpperCase();
b = b.toUpperCase();
a = a.toLowerCase();
b = b.toLowerCase();
return a < b ? -1 : a > b ? 1 : 0;
});

Expand Down

0 comments on commit ece8485

Please sign in to comment.