I'm trying to sort the below rendered list of names into alphabetical order. I think I would use the sort method but I'm not sure how to do it? Here's what I have:
useEffect(() => {
if (selectedPeople.length > 0) {
let allSources = [];
let sharedSources = [];
const duplicateSources = selectedPeople.map(user => {
return Object.keys(user.groups);
}).flat();