DEV Community

Cover image for Sorting comparator
David Armendáriz
David Armendáriz

Posted on

Sorting comparator

In Javascript, we have the sort method for arrays. If "a" is less than "b" by some ordering criterion, then we return -1. If "a" is greater than "b" by the ordering criterion, we return 1. This is the basic idea to sort things. We can do the same for Python. In this video, I solve the problem of sorting by a score in descending order and then by name in ascending order.

Top comments (0)