Fix ranking and sorting.

Signed-off-by: Thomas Marques <marquesthom@gmail.com>