0

I have multi level object with structure like below

{
  "28300": {
    "ceiv": "7.89",
    "cenormal": "0 ",
    "cechange": "0.00"
  },
  "28400": {
    "ceiv": "7.89",
    "cenormal": "0 ",
    "cechange": "0.00"
  },
  "28500": {
    "ceiv": "98.60",
    "cenormal": "0.27 ",
    "cechange": "-2.21"
  },
  "28600": {
    "ceiv": "7.89",
    "cenormal": "0 ",
    "cechange": "0.00"
  },
  "28700": {
    "ceiv": "7.89",
    "cenormal": "0 ",
    "cechange": "0.00"
  }
}

How do I sort by ceiv in ascending and descending.

I have tried something like below

data.sort(({ ceiv: a }, { ceiv: b }) => b - a);

But its not sorting , thank you.

Gracie williams
  • 943
  • 1
  • 6
  • 20

0 Answers0