Database
[{_id:ObjectId("5e8e2d28ca6e660006f263e6"),match:{_id:2345,abc:1}},{_id:ObjectId("5e8e2d28ca6e660006f263e7"),match:{_id:2345,abc:1}},{_id:ObjectId("5e8e2d28ca6e660006f264d0"),match:{_id:7890,abc:2}},{_id:ObjectId("5e8e2d28ca6e660006f264d1"),match:{_id:7890,abc:2}}]
Query
db.collection.aggregate([{$sort:{_id:1}},{$group:{_id:"$match._id",doc:{$first:"$$ROOT"}}},{$replaceRoot:{newRoot:"$doc"}}])