tri.js généralisation tri par numéro (croissant/décroissant)

This commit is contained in:
Jean-Christophe Engel 2024-06-14 10:10:33 +02:00
parent 944aed6fd2
commit 33aa593e9d

3
tri.js
View File

@ -9,7 +9,8 @@ function trierNumeros(tnumeros, tnoms, croissant = true)
o.nom = tnoms[i];
tab.push(o);
}
tab.sort((a, b) => { return a.numero - b.numero; });
ordre = croissant ? 1 : -1;
tab.sort((a, b) => { return ordre * (a.numero - b.numero); });
return tab;
}