Since ranking is done within specific "grouping", you're probably not surprised that $group stage is going to be involved. To get the scores (whatever you want to rank by) in order you can use $sort on that field first (assuming you have an index to support it) or you can $group with $push first and then sort the array in each document. Then you need to do ranking. Because it's a pretty complex expression, I created a helper function that generates it based on appropriate inputs:
"sal" : "$$this.sal",
$mergeObjects is only one of many great enhancements coming to MongoDB 3.6.