Похожие чаты

Please I am trying to sort an array of nested

arrays. I tried sorting out items in array according to date and mapping the data but I'm facing issues. Any assistance?

8 ответов

9 просмотров

Code??

Your question is lacking. Please include: - What you have - What you want - What you have tried - The results of what you tried - Any error messages For example: "I have the string "52 854". I want it as the number 52854. I tried using Number("52 854"), but it just becomes NaN. I also tried Number.parseInt("52 854"), but it became just 52. What am I doing wrong?" For a more detailed guide, see StackOverflow's guide to asking

generally, nestedArr.sort(subArr => Math.max(...subArr.map(_ => _.date)))

something like nestedArr.sort((a, b) => Math.max(...a.map(_ => _.date)) > Math.max(...b.map(_ => _.date)) ? -1 : 1)

Bt-Baw Автор вопроса

{ "products": [ { "id": 1, "name": "Product 1", "prices": [ { "id": 1, "price": 46, "date": "2019-01-01T17:16:32+00:00" }, { "id": 2, "price": 34, "date": "2018-11-01T17:16:32+00:00" } ] }, { "id": 2, "name": "Product 2", "prices": [ { "id": 3, "price": 45, "date": "2019-01-01T17:16:32+00:00" }, { "id": 4, "price": 56, "date": "2018-11-01T17:16:32+00:00" } ] }, { "id": 3, "name": "Product 3", "prices": [ { "id": 5, "price": 56, "date": "2017-01-01T17:16:32+00:00" }, { "id": 6, "price": 46, "date": "2018-11-01T17:16:32+00:00" } ] } ] }

Bt-Baw Автор вопроса
Simen
Your question is lacking. Please include: - What y...

{ "products": [ { "id": 1, "name": "Product 1", "prices": [ { "id": 1, "price": 46, "date": "2019-01-01T17:16:32+00:00" }, { "id": 2, "price": 34, "date": "2018-11-01T17:16:32+00:00" } ] }, { "id": 2, "name": "Product 2", "prices": [ { "id": 3, "price": 45, "date": "2019-01-01T17:16:32+00:00" }, { "id": 4, "price": 56, "date": "2018-11-01T17:16:32+00:00" } ] }, { "id": 3, "name": "Product 3", "prices": [ { "id": 5, "price": 56, "date": "2017-01-01T17:16:32+00:00" }, { "id": 6, "price": 46, "date": "2018-11-01T17:16:32+00:00" } ] } ] } So I have this array of products and I have mapped the data, but I want the key prices to return the sorted array of prices in order of recent date

Bt-Baw Автор вопроса
Bt Baw
{ "products": [ { "id":...

Hope you get it now @Suppen

Bt-Baw Автор вопроса

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта