I do not understand how does sort() method work on the array of objects

https://www.codecademy.com/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/web-dev-intermediate-javascript-practice/lessons/intermediate-javascript-coding-challenge/exercises/sort-species-by-teeth

I have been working on this exercise. Actually, I found the solution, I understood how to write the code, but I do not understand how does sort() method sorts certain values of the objects.

I do not understand why do we have to subtract one value from another, and how do we recieve the sorted array of objects.

Thanks in advance

Functions make some kind of promise about how they behave.
What does array’s sort method promise?
You’d need to read that promise, wouldn’t you.
You’d need to do that for anything you use if you’re to be confident about leveraging it in a sensible way.

Documentation.
Where? Google to the rescue.

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.