Mongodb sort with case insensitive manner
Create the collection with a default collation by this way you can order by any property with case insensitive.
db.createCollection("collection_name", { collation: { locale: 'en_US', strength: 2 } } )
db.getCollection('collection_name').find({}).sort( { 'property_name': -1 } )
More info: https://docs.mongodb.com/manual/core/index-case-insensitive/
You need to use collation
here with locale: "en"
db.collection.find({}).collation({ locale: "en" }).sort({ name: 1 })
So for the below document
{ "_id" : 1, "name" : "Bhavik" }
{ "_id" : 2, "name" : "Jay" }
{ "_id" : 3, "name" : "atul" }
You will get
{ "_id" : 3, "name" : "atul" }
{ "_id" : 1, "name" : "Bhavik" }
{ "_id" : 2, "name" : "Jay" }