How to make sorting functional well if it is case sensitive. how can we make it correct
Please suggest best way to fix it
db.products.aggregate([
{
"$unwind": "$receipe"
},
{
"$unwind": "$receipe.burger"
},
{
"$sort": {
"receipe.burger.name": 1
}
}
])
https://mongoplayground.net/p/2pnUABI_-Mr
in my example familyburger should display first rather than Paneer Burger.
Demo - https://mongoplayground.net/p/Vt3GQx0tdXC
db.products.aggregate([
{ "$unwind": "$receipe" },
{ "$unwind": "$receipe.burger" },
{ $addFields: { "insensitiveName": { $toLower: "$receipe.burger.name" } } },
{ $sort: { "insensitiveName": 1 } }
])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With