const Contacts = ({ contacts }) => { console.log(contacts); // map for contact separation // add only if there are contacts for that letter const letterSectionMap = {}; // { // "L": [allen, alejandro], // "" // } contacts.forEach((ct) => { // if its in the map already, then we add to the array const firstLetterOfLastName = ct.lastName[0]; // todo: keep the array if (firstLetterOfLastName in letterSectionMap) { letterSectionMap[firstLetterOfLastName].push(ct); return; } else { letterSectionMap[firstLetterOfLastName] = [ct]; } }); // sort by last name first and then first name // const sortedContacts = contacts.sort((a, b) => { // if (a.lastName > b.lastName) { // return 1; // } else if (b.lastName > a.lastName) { // return -1; // } else if (b.lastName == a.lastName) { // if (a.firstName > b.firstName) { // return 1; // } else if (b.firstName > a.firstName) { // return -1; // } // } // return 0; // }); // sort the map by the first letter of last name const sortedKeys = Object.keys(letterSectionMap); console.log(letterSectionMap); return (