Database

[{"_id":ObjectId("5b29fc8a0d206c33115cdf84"),"Cost":10,"Desc":"Cost of security","Category":"C1","Vendor":"Vendor 2"},{"_id":ObjectId("5b29fc8a0d206c33115cdf7d"),"Cost":190,"Desc":"Total Cost of Ownership","Category":"C1","Vendor":"Vendor 2"},{"_id":ObjectId("5b29fc8a0d206c33115cdf85"),"Cost":10,"Desc":"Cost of training","Category":"C1","Vendor":"Vendor 2"},{"_id":ObjectId("5b29fc8a0d206c33115cdf86"),"Cost":10,"Desc":"Total Cost of Ownership","Category":"C1","Vendor":"Vendor 1"},{"_id":ObjectId("5b29fc8a0d206c33115cdf87"),"Cost":20,"Desc":"Cost of purchase","Category":"C1","Vendor":"Vendor 3"},{"_id":ObjectId("5b29fc8a0d206c33115cdf88"),"Cost":40,"Desc":"Cost of repairs","Category":"C1","Vendor":"Vendor 3"}]

Query

db.collection.aggregate([{$group:{_id:{Desc:"$Desc",Vendor:"$Vendor"},sum:{"$sum":"$Cost"}}},{$group:{_id:"$_id.Desc",Value:{$push:{Vendor:"$_id.Vendor",value:"$sum"}}}},{$sort:{"Value.Vendor":1}}])

Result