This is my array, I have an object and then a count of how many repeats Id have for example the first object has the Id 2 repeated 3 times.
[{
  Id: 1,
  Info: "Info",
  Category: [
    { Id: 2, count: 3 },
    { Id: 4, count: 1 },
    { Id: 8, count: 1 },
    { Id: 18, count: 1 },
    { Id: 9, count: 1 },
    { Id: 3, count: 1 },
  ],
}, {
  Id: 2,
  Info: "Info 2",
  Category: [
    { Id: 2, count: 3 },
    { Id: 9, count: 2 },
    { Id: 21, count: 1 },
    { Id: 3, count: 1 },
  ],
}, {
  Id: 3,
  Info: "Info 3",
  Category: [
    { Id: 4, count: 1 }, 
    { Id: 11, count: 1 }, 
    { Id: 9, count: 1 },
  ],
}]
Now I need to order this array based on an Id for example the number "9" so if the first object has the Maximus count of the id 9 of all it will be the first and the others whit minus count would be bellow, like this, the number 9 will be a random number.
[{
  Id: 2,
  Info: "Info 2",
  Category: [
    { Id: 2, count: 3 },
    { Id: 9, count: 2 },
    { Id: 21, count: 1 },
    { Id: 3, count: 1 },
  ],
}, {
  Id: 1,
  Info: "Info",
  Category: [
    { Id: 2, count: 3 },
    { Id: 4, count: 1 },
    { Id: 8, count: 1 },
    { Id: 18, count: 1 },
    { Id: 9, count: 1 },
    { Id: 3, count: 1 },
  ],
}, {
  Id: 3,
  Info: "Info 3",
  Category: [
    { Id: 4, count: 1 }, 
    { Id: 11, count: 1 }, 
    { Id: 9, count: 1 },
  ],
}]
 
     
     
    