Sort in a facet pipeline produces (consistently) strange results

I am trying to understand why having a sort stage in a facet pipeline causes documents to appear more than once on different pages. Note that I solved this problem by moving the sort stage into the main pipeline, but would like to understand if this is a bug.

Example code

    pipeline.push({
      $facet: {
        total: [{ $count: 'count' }],
        docs: [$sort, $skip, $limit],
      },
    });

The main pipeline has just a basic $match stage. The idea is, there’s no point to sort when obtaining the total count, so just put that in the docs pipeline. However, when adding any skip/limit values, you get the same documents on different pages, very consistently.

Why does this occur? Why did I need to move sort stage into the main pipeline?