[SERVER-76979] $sortArray does not provide correct results in case of case-sensitive data Created: 10/May/23 Updated: 18/May/23 Resolved: 11/May/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | 6.0.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Amanpreet Singh | Assignee: | Backlog - Triage Team |
| Resolution: | Done | Votes: | 0 |
| Labels: | Bug | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Assigned Teams: |
Server Triage
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Steps To Reproduce: | // Insert records
sort on a field:
// Result of the above query
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Participants: |
| Description |
|
The sorting of array data using `$sortArray` is not correct. You can check the link - https://mongoplayground.net/p/c61hwM85OG1 |
| Comments |
| Comment by Amanpreet Singh [ 18/May/23 ] | |||||||||||||||||||||||||||||||||||||
|
Thanks, Eric for the update. Can you please let me know, how we can improve the MongoDB docs and present this as an example? | |||||||||||||||||||||||||||||||||||||
| Comment by Eric Sedor [ 11/May/23 ] | |||||||||||||||||||||||||||||||||||||
|
$sortArray is lexicographic by default. You'll need to specify a collation:
For further questions about crafting the right query for your use-case I encourage you to start by asking our community for help by posting on the MongoDB Developer Community Forums.
Thanks, | |||||||||||||||||||||||||||||||||||||
| Comment by Yuan Fang [ 11/May/23 ] | |||||||||||||||||||||||||||||||||||||
|
Thank you for your report. It appears that the result of sorting by name in ascending order is correct, as the names are sorted as "Dallas", "charlie", "dallas", and "pat". Could you please elaborate on why you believe the result is incorrect? Regards, |