-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Blocker - P1
-
None
-
Affects Version/s: 8.0.12, 8.2.5
-
Component/s: None
-
None
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Have the following (abbreviated) aggregate pipeline (go):
```
bson.A{
bson.M{
"$match": bson.M
,
},
bson.M
,
bson.M{
"$match": bson.M{
"subdocuments.work_date": bson.M
,
},
},
bson.M{
"$replaceRoot": bson.M
,
},
bson.M{
"$sort": bson.M
,
},
}
```
On Mongodb v7.0.29, this works as expected and I see the documents sorted as expected (wd is the work_date value):
```
2026/02/13 15:06:24 wd: 2025-04-01
2026/02/13 15:06:24 wd: 2025-04-01
2026/02/13 15:06:24 wd: 2025-04-01
2026/02/13 15:06:24 wd: 2025-04-01
2026/02/13 15:06:24 wd: 2025-04-01
2026/02/13 15:06:24 wd: 2025-04-02
2026/02/13 15:06:24 wd: 2025-04-02
2026/02/13 15:06:24 wd: 2025-04-02
2026/02/13 15:06:24 wd: 2025-04-02
2026/02/13 15:06:24 wd: 2025-04-03
2026/02/13 15:06:24 wd: 2025-04-03
2026/02/13 15:06:24 wd: 2025-04-03
2026/02/13 15:06:24 wd: 2025-04-03
2026/02/13 15:06:24 wd: 2025-04-04
...output cut here for brevity...
```
However, on MongoDB v8+ on Linux, both bare metal and docker images, the following sort order is returned (wd is the work_date value):
```
2026/02/13 15:06:29 wd: 2025-04-08
2026/02/13 15:06:29 wd: 2025-04-06
2026/02/13 15:06:29 wd: 2025-04-06
2026/02/13 15:06:29 wd: 2025-04-06
2026/02/13 15:06:29 wd: 2025-04-06
2026/02/13 15:06:29 wd: 2025-04-07
2026/02/13 15:06:29 wd: 2025-04-07
2026/02/13 15:06:29 wd: 2025-04-07
2026/02/13 15:06:29 wd: 2025-04-07
2026/02/13 15:06:29 wd: 2025-04-08
2026/02/13 15:06:29 wd: 2025-04-08
2026/02/13 15:06:29 wd: 2025-04-05
2026/02/13 15:06:29 wd: 2025-04-08
2026/02/13 15:06:29 wd: 2025-04-09
```
This was also reproducible with rancher-desktop on MacOS using both the official docker image and the mongodb docker image so it's not limited to one hardware system running Linux.