JavaScript how to ❓ sort an array of objects by string property value

preview_player
Показать описание
#javascirpt #javascriptarrays #javascriptarrayofobjects
How do you sort an array of objects based on property values?
Sorting an Array of Objects by String Property Value in Javascript
Рекомендации по теме
Комментарии
Автор

Could've done it like this
cities.sort((city1, city2)=>city1.name.toLocaleCompare(city2.name))

internetexplorer
Автор

I just loved the rain background noise. Mad props!

theincredibleillmo
Автор

Hi, I don't get what does it do when you use > or < in an if comparing strings, of coursr I know you can do if(3 > 5) but what does if("A city" > "Another city name") mean? Or did I not understand another part?

fabriperoconalgomasytodojunto
Автор

I think it would be better to create separated variables for object names :)

thegate
Автор

Did you record this in the middle of a monsoon?

HH_
Автор

sort({name: nameA}, {name: nameB}) => ...
much better

pavloburyanov