DEV Community

Discussion on: How to sort an array of objects using the JS Sort Method

Collapse
 
joolsmcfly profile image
Julien Dephix • Edited
list_of_animals.map((list)=>list.toLowerCase()).sort()
Enter fullscreen mode Exit fullscreen mode

map returns a copy of the original array so you need to assign the result back to list_of_animals.

list_of_animals = list_of_animals.map((list)=>list.toLowerCase()).sort()
Enter fullscreen mode Exit fullscreen mode

Or you could compare lowercase strings in the sort method.