DEV Community

Discussion on: How does this alphabetical-sorting function work?

Collapse
 
daviddoes profile image
David Clark • Edited

Yes, yes, yes! It's all coming back now.

Follow-up:

Here is the rest of what I'm doing with this data:

    let momentsList = [];
    this.props.moments.forEach(({ id, location }) => momentsList.push({ id, location }));
    let uniqueSet = [...new Set(momentsList.map(moment => moment.location))];

The data being returned, stored in momentsList, and manipulated, is an array of objects (as you can see). Using let sortedList = uniqueSet.sort() worked for it. I think because I'm getting the id and location, then mapping the location.