How to sort river by likes?

I want to sort river by likes , most liked content is on top , I've see the code in engine/lib/river.php and pages/river.php , but i don't understand how to sort it.

sorry for my bad english