Skip to content

Instantly share code, notes, and snippets.

View jvluv11's full-sized avatar
😍
Software engineer, Full Stack JavaScript developer (MERN & MEAN) 🙂

Vladimir Jean jvluv11

😍
Software engineer, Full Stack JavaScript developer (MERN & MEAN) 🙂
View GitHub Profile
@umidjons
umidjons / sort-object-properties-by-value.md
Last active October 9, 2024 10:31
JavaScript: sort object properties by value (numeric or string)

Sort object properties by value (values are text)

I have following object:

var cities={10:'Tashkent', 14:'Karakalpakiya', 16:'Andijan'};

I want sort it by city names, so after sort it should be:

var cities={16:'Andijan', 14:'Karakalpakiya', 10:'Tashkent'};

But I can't sort object properties, instead can convert object into array, then sort items.