Marcus
Marcus

Reputation: 57

How to sort a map by a specific field in js (react)?

How can I sort this by name?

Can anybody help me with that?

Upvotes: 0

Views: 53

Answers (1)

Murat Karagöz
Murat Karagöz

Reputation: 37584

You can sort the array beforehand with Array#sort e.g.

underlyings.sort((a, b) => a.name.localeCompare(b.name));

Upvotes: 3

Related Questions