Sort mapped entries
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user