Database
[{"key":1,"user":"A","comment":"commentA1"},{"key":2,"user":"A","comment":"commentA2"},{"key":5,"user":"A","comment":"commentA5"},{"key":2,"user":"B","comment":"commentB2"},{"key":3,"user":"B","comment":"commentB3"},{"key":6,"user":"B","comment":"commentB6"}]
Query
db.collection.aggregate([{$sort:{"key":1}},{$group:{_id:"$user",data:{$push:{key:"$key",comment:"$comment"}}}},{$set:{secondInx:{$first:{$reduce:{input:{$range:[1,{$size:"$data"}]},initialValue:[],in:{$concatArrays:["$$value",{$cond:[{$eq:[{$subtract:[{$arrayElemAt:["$data.key","$$this"]},{$arrayElemAt:["$data.key",{$subtract:["$$this",1]}]}]},1]},["$$this"],[]]}]}}}}}},{$project:{data:[{$arrayElemAt:["$data","$secondInx"]},{$arrayElemAt:["$data",{$subtract:["$secondInx",1]}]}]}},{$unwind:"$data"},{$project:{comment:"$data.comment",key:"$data.key"}}])