order an array of objectes typed CollegioVerbale { id: CollegioVerbaleID; idRicUdien:…
- User
order an array of objectes typed CollegioVerbale { id: CollegioVerbaleID; idRicUdien: number; tipoMag: string; gradoMag: number; magistrato?: AnagraficaMagistratoCollegio; riserva: boolean; relatore: boolean; operatore: number; comparso: boolean; oggi: number; }
put at the bottom of array all the objects with riserva true and order them by gradoMag ascendant
- Assistant
const sortedArray = array.filter(obj => obj.riserva === true).sort((a,b) => a.gradoMag - b.gradoMag); array = array.filter(obj => obj.riserva !== true).concat(sortedArray);
- User
order an array of objectes typed CollegioVerbale { id: CollegioVerbaleID; idRicUdien: number; tipoMag: string; gradoMag: number; magistrato?: AnagraficaMagistratoCollegio; riserva: boolean; relatore: boolean; operatore: number; comparso: boolean; oggi: number; } put first all the objects with tipoMag === 'PRE' then all the objects with tipoMag==='CON' and order them by gradoMag ascendant and then at the bottom of array all the objects with riserva true and order them by gradoMag ascendant
- Assistant
const preArray = array.filter(obj => obj.tipoMag === 'PRE').sort((a,b) => a.gradoMag - b.gradoMag); const conArray = array.filter(obj => obj.tipoMag === 'CON').sort((a,b) => a.gradoMag - b.gradoMag); const riservaArray = array.filter(obj => obj.riserva === true).sort((a,b) => a.gradoMag - b.gradoMag); array = preArray.concat(conArray).concat(riservaArray).concat(array.filter(obj => obj.tipoMag !== 'PRE' && obj.tipoMag !== 'CON' && obj.riserva !== true));
- User
order an array of objectes typed CollegioVerbale { id: CollegioVerbaleID; idRicUdien: number; tipoMag: string; gradoMag: number; magistrato?: AnagraficaMagistratoCollegio; riserva: boolean; relatore: boolean; operatore: number; comparso: boolean; oggi: number; } put first all the objects with tipoMag === ‘PRE’ then all the objects with tipoMag===‘CON’ and order them by gradoMag ascendant and then at the bottom of array all the objects with riserva true and order them by gradoMag ascendant
and remove duplicates
- Assistant
const preArray = array.filter(obj => obj.tipoMag === 'PRE').sort((a,b) => a.gradoMag - b.gradoMag); const conArray = array.filter(obj => obj.tipoMag === 'CON').sort((a,b) => a.gradoMag - b.gradoMag); const riservaArray = array.filter(obj => obj.riserva === true).sort((a,b) => a.gradoMag - b.gradoMag); array = preArray.concat(conArray).concat(riservaArray).concat(array.filter(obj => obj.tipoMag !== 'PRE' && obj.tipoMag !== 'CON' && obj.riserva !== true)); const uniqueArray = array.filter((obj, index, self) => index === self.findIndex((t) => ( t.id === obj.id )) ); array = uniqueArray;
- User
i have an array of objectes typed CollegioVerbale { id: CollegioVerbaleID; idRicUdien: number; tipoMag: string; gradoMag: number; magistrato?: AnagraficaMagistratoCollegio; riserva: boolean; relatore: boolean; operatore: number; comparso: boolean; oggi: number; } put first all the objects with tipoMag === ‘PRE’ then all the objects with tipoMag===‘CON’ and order them by gradoMag ascendant and then at the bottom of array all the objects with riserva true and order them by gradoMag ascendant
- Assistant
const preArray = array.filter(obj => obj.tipoMag === 'PRE').sort((a,b) => a.gradoMag - b.gradoMag); const conArray = array.filter(obj => obj.tipoMag === 'CON').sort((a,b) => a.gradoMag - b.gradoMag); const riservaArray = array.filter(obj => obj.riserva === true).sort((a,b) => a.gradoMag - b.gradoMag); array = preArray.concat(conArray).concat(riservaArray).concat(array.filter(obj => obj.tipoMag !== 'PRE' && obj.tipoMag !== 'CON' && obj.riserva !== true));