Skip to content
Advertisement

Object’s values sorted in desecending order

I have this object:

JavaScript

Each gladiator has its own abilities and as values are the skill for each ability, I want to print them in desecending order by total skill, this is where I am at the moment:

JavaScript

this code prints:

JavaScript

I simply want it to print:

JavaScript

I want the total skill to be in descending order, if its equal, sort in ascending order, the same for each ability the gladiator has. Please suggest me how can I make my question more clear if I have mistakes I read the guide a few times.

Advertisement

Answer

We should be able to use Object.entries and Array.sort to arrange the objects as we wish, then print out the results:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement