DEV Community

loading...

Discussion on: How to sort array of object using object keys in JavaScript?

Collapse
7tonshark profile image
Elliot Nelson

For the string comparison, you can also simplify using the localeCompare function, which returns a negative, positive, or zero value for you:

return x.localeCompare(y);
Enter fullscreen mode Exit fullscreen mode
Forem Open with the Forem app