Returning sorted results by number of matches

Something like this:

q(func: type(deal),first:5, orderasc: matches) @filter(uid(deal_uids))  {

You might need to put your core query into a subquery first. If you have some data and schema, I can reproduce and give you the full answer