-3

My objects key consists of alphanumeric text and I want the final object to be sorted by A1 object first then A2 object etc... when all A objects are sorted then B1, B2 etc..

    const myObject = {
  "A1": {
    "sum": 1,
    "count": 1,
    "average": "1.00"
  },  
  "A13": {
    "sum": 5,
    "count": 1,
    "average": "5.00"
  },
  "A2": {
    "sum": 6,
    "count": 3,
    "average": "2.00"
  },
  "B10": {
    "sum": 4,
    "count": 1,
    "average": "4.00"
  },
  "Z5": {
    "sum": 8,
    "count": 1,
    "average": "8.00"
  },
  "B1": {
    "sum": 3,
    "count": 1,
    "average": "3.00"
  },
  "D1": {
    "sum": 2,
    "count": 1,
    "average": "2.00"
  },
  "E1": {
    "sum": 7,
    "count": 2,
    "average": "3.50"
  },
  "M1": {
    "sum": 41,
    "count": 14,
    "average": "2.93"
  }
}
Lee Taylor
  • 7,155
  • 14
  • 29
  • 44
Karim Ali
  • 1,815
  • 4
  • 19
  • 29
  • 1
    You can't reorder the properties of an object. Objects remember the order that the properties were added. If you care about order, you should be using an array. – Barmar May 13 '22 at 22:41

0 Answers0