Database

[{"key":1,"dt":ISODate("2006-01-02T15:04:35Z")},{"key":2,"dt":ISODate("2006-01-02T16:04:21Z")},{"key":3,"dt":ISODate("2006-01-02T18:04:05Z")}]

Query

db.collection.aggregate([{$addFields:{sec:{$second:"$dt"}}},{$addFields:{order_no:{$mod:["$sec",5]}}},{$sort:{order_no:1,dt:1}}])

Result