re: How does this alphabetical-sorting function work? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: .sort is a function in JavaScript. It modifies the list in place, so uniqueSet is also affected by this, not just sortedList. (It just also returns...
 

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.

code of conduct - report abuse