Hey Raj,
It uses priorities to determine the order, but you can nowadays accomplish the same with any property. The trick to get descending order is to invert the number of likes, so:
item.order = -1 * item.likes.
Then you can run a query that gets the number of item you want to show:
ref.orderByChild("order").limitToFirst(10).on("child_added", function(snapshot, previousChildKey) {
On the initial load, the children will arrive in the correct order. So it is tempting to simply append them to your data. But after the initial data has loaded, the query will still be monitoring for changes. Once an item gets a higher number of likes than are currently in the data, you will get a child_removed event for the least-liked item and a child_added for the new favorite item.
The leaderboard sample handles this in the best way: when Firebase calls you child_added callback, it passes a previousChildKey. You can use this to look up the previous child's element in the HTML and insert the new favorite item in its correct place.