Concept Flow - $first and $last accumulators
Start with documents
Sort documents if needed
Group documents by key
$first picks first document's field
$last picks last document's field
Output grouped results with $first and $last values
Documents are sorted if needed, then grouped by a key. $first and $last pick the first and last values from each group after sorting.
