From da25d620342588c8a72d8d3f63840b94efd59d14 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Mon, 10 Jun 2024 13:55:36 +0200 Subject: [PATCH] =?UTF-8?q?code.js=20:=20suppression=20tri=20parents=20d?= =?UTF-8?q?=C3=A9plac=C3=A9=20dans=20tri.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code.js | 58 --------------------------------------------------------- 1 file changed, 58 deletions(-) diff --git a/code.js b/code.js index 1eddc26..54baa92 100644 --- a/code.js +++ b/code.js @@ -160,64 +160,6 @@ function selParent(lesnoms, lesparents, nb) } return selParent(${lesnoms}, ${lesparents}, ${nb_total_membres}) -// trier les membres selon le parent -// critères : -// - id_parent IS NULL -// - nom_parent -// - nom_membre -// - numero -function trierParents(tparents, tnoms, tnumeros, croissant = true) -{ - let tab = []; - for (let i = 0; i < tnumeros.length; ++i) { - let o = Object(); - o.numero = tnumeros[i]; - o.nom = tnoms[i]; - o.parent = tparents[i]; - tab.push(o); - } - tab.sort((a, b) => { - if (! croissant) { [a, b] = [b, a]; } - let comp = a.parent.localeCompare(b.parent); - if (comp == 0) { comp = a.nom.localeCompare(b.nom); } - if (comp == 0) { comp = a.numero - b.numero; } - return comp; - }); - /* - if (a.parent === "") { - if (b.parent === "") { - // deux parents vides => comparer les noms - return a.nom.localeCompare(b.nom); - } - else { - return 1; - } - } - else { - if (b.parent === "") { - return -1; - } - else { - // deux parents non vides => comparer les noms - let comp = a.parent.localeCompare(b.parent); - if (comp == 0) { - comp = a.nom.localeCompare(b.nom); - } - return comp; - } - } - }); - */ - - return tab; -} -let tab = trier(${lesnumeros}, ${lesnoms}, ${lesparents}); -let resu = []; -tab.forEach((e) => { - resu.push(e.nom); -}); -return resu; - // ------------------------------------------------------------------------ // normaliser une chaîne : // - mettre en minuscules