commentsArray sorted

This commit is contained in:
nicola 2023-12-17 18:13:16 +01:00
parent 5958bdbf16
commit 97190cec5d
1 changed files with 18 additions and 1 deletions

View File

@ -744,6 +744,23 @@ function resetFrasi(){
commentsArray.forEach(removeHtmlTags2) commentsArray.forEach(removeHtmlTags2)
//console.log("Array dopo") //console.log("Array dopo")
//console.log(commentsArray) //console.log(commentsArray)
//commentsArray.sort(function(a, b){return a.verso - b.verso});
var numVerso1;
var numVerso2;
commentsArray.sort((p1, p2) => {
numVerso1 = p1.verso;
numVerso2 = p2.verso;
numVerso2 = numVerso2.replaceAll("_","");
numVerso1 = numVerso1.replaceAll("_","");
numVerso2 = parseInt(numVerso2);
numVerso1 = parseInt(numVerso1);
if (numVerso1 < numVerso2) return -1;
if (numVerso1 > numVerso2) return 1;
return 0;
});
console.log("Array dopo")
} }
/* Luca: removeHtmlTags2 e' la versione compatta di removeHtmlTags*/ /* Luca: removeHtmlTags2 e' la versione compatta di removeHtmlTags*/