Sort mapped entries

This commit is contained in:
2025-11-11 10:48:34 +01:00
parent 859fb0e19e
commit 3d9266fdd9
3 changed files with 20 additions and 6 deletions

View File

@@ -284,12 +284,13 @@ class ConcPage {
const resultsWrap = document.createElement("div");
convertB.addEventListener('click', function() {
let lines = [];
let keysAreNumeric = false;
if (listOptions[1] !== undefined && listOptions[1] !== null) {
keysAreNumeric = true;
}
// First gather lines by target type for rough sorting
let linesByType = {};
for (let m of matchSelects) {
let line = ("'" + m.getAttribute("data-input") + "'").padEnd(40, " ") + " => ";
@@ -300,11 +301,24 @@ class ConcPage {
line += "'" + m.value + "',";
}
line += ' // ' + listOptionsEn[m.value];
lines.push(line);
// A
if (linesByType[m.value] === undefined) {
linesByType[m.value] = [];
}
linesByType[m.value].push(line);
m.setAttribute("readonly", "readonly");
}
// Then put the lines together so they can be joined
let lines = [];
for (let key in linesByType) {
for (let l of linesByType[key]) {
lines.push(l);
}
}
const output = " ".repeat(8) + lines.join("\n" + " ".repeat(8));
console.log(output);

File diff suppressed because one or more lines are too long