Database

[{"customer":"WN","sort_category":"category_b","locations":[{"city":"Elkana","category_a":11904.0,"category_b":74.0,"category_c":657.0},{"city":"Haifa","category_a":20.0,"category_b":841.0,"category_c":0},{"city":"Jerusalem","category_a":451.0,"category_b":45.0,"category_c":712.0}]}]

Query

db.collection.aggregate([{$addFields:{locations:{$map:{input:"$locations",as:"l",in:{$mergeObjects:["$$l",{category:{$reduce:{input:{$objectToArray:"$$l"},initialValue:null,in:{$cond:[{$eq:["$$this.k","$sort_category"]},"$$this.v","$$value"]}}}}]}}}}},{$unwind:"$locations"},{$sort:{"locations.category":1}},{$project:{"locations.category":0}},{$group:{_id:"$_id",customer:{$first:"$customer"},sort_category:{$first:"$sort_category"},locations:{$push:"$locations"}}},{$project:{_id:0}}])

Result