Skip to main content

All Questions

0 votes
1 answer
70 views

Javascript sort nested array objects

I need to return the same array, same structure, I need to loop inside each array object and reorder the planningDiagnosi. I need to have tha array content sorted by outcomeStatusId from the lowest to ...
Matteo F's user avatar
-1 votes
3 answers
270 views

How can I sort an object alphabetically by value?

So I have a list of countries, by default they come sort by ISOA2 Code which is some kind of country code. Say this list: { "AD": "Andorra", "AE": "United Arab ...
Reacting's user avatar
  • 5,963
1 vote
2 answers
208 views

Sort array of objects based on string parameter

I have the following array of objects: [ { "id" : 1, "pricePerDay" : 50, }, { "id" : 2, "pricePerDay" : 70 ...
Bowis's user avatar
  • 611
-2 votes
2 answers
76 views

Sort array of complex object by date in string format

I need to sort this array called gridObj, by key.expiry.value. I tried the following with no result: const sorted = Object.keys(gridObj).map((val) => gridObj[val]?.expiry?.sort((a, b) => { ...
palnic's user avatar
  • 416
1 vote
2 answers
130 views

Sort array of object by key in date string format

How can I sort this type of object? const obj = [{ "02/10/2021": 291692.14, "08/12/2023": 140908.90579999998, "09/04/2021": 14.4776, "09/06/2023": 863....
Salvatore Difranco's user avatar
0 votes
1 answer
54 views

How to convert an array of objects (of different lengths) into one object that has different properties from the elements in the original array?

I'm trying to make an app that uses data from the flickr api (I'll be only using the open license images and crediting the author, etc.). I'm querying the flickr api and then parsing the results into ...
Kyle Pennell's user avatar
  • 6,007
0 votes
2 answers
121 views

How to group and sort object array?

I've got an object array which I have to group and sort: [ { id: 123, group: 'abc', metadata: { name: 'tom' }, date: ISODate("2019-07-08T20:33:40.475Z") }, { id: ...
user3142695's user avatar
  • 16.9k
5 votes
2 answers
110 views

Write a function to sort an array of objects (by using another object to specify the sorting path and order )

I'm going to write a function to sort any JSON with somehow any structure (just know it's an array of objects, e.g. a list of products) by using another object as its argument to determine which ...
Bawbak's user avatar
  • 105
4 votes
4 answers
13k views

Sort a JavaScript object by key or value; ES6

Before I ask; there are a bunch of discussions on this particular subject, most of which pertain to ES5 and do not necessarily hold truth for ES6. I'm attempting to get some clarification, and maybe ...
artomason's user avatar
  • 3,853
8 votes
7 answers
2k views

Sort objects in array with dynamic nested property keys

I'm trying to sort an array of nested objects. It's working with a static chosen key but I can't figure out how to get it dynamically. So far I've got this code sortBy = (isReverse=false) => { ...
Thore's user avatar
  • 1,698
0 votes
2 answers
690 views

Sort array based on presence of fields in objects

How can I sort array something like below if any of fields is missing? So existing array for example is: const users = [ { id: 1, firstname: 'Jerry' }, { id: 2, firstname: '...
hofshteyn's user avatar
  • 1,272
0 votes
2 answers
61 views

How to sort values in the same object that are in another object in javascript

I already sorted objects by pushing them in an array, but I am not sure on how to do the same, cleanly, in this situation (values in the same object in an object, in another object). I'd like to sort ...
Pierre Hofman's user avatar