Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-13063

Add the sort behaviour in the aggregation push accumlator

      Description

      Can we add a sort behavior for push operator just like we have for last and first accumulator ?

      https://docs.mongodb.com/manual/reference/operator/aggregation/last/#behavior

      https://docs.mongodb.com/manual/reference/operator/aggregation/first/#behavior

      Something like

      Behavior

      When using $push in a $group stage, the $group stage should follow a $sort stage to have the input documents in a defined order.
       

      NOTE

      Although the $sort stage passes ordered documents as input to the $group stage, $group is not guaranteed to maintain this sort order in its own output.
       
       

       

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

            Assignee:
            naomi.pentrel@mongodb.com Naomi Pentrel (Inactive)
            Reporter:
            Sagar Sagar
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              3 years, 1 week, 2 days ago