MongoDB: Sort UTF-8 strings MongoDB: Sort UTF-8 strings mongoose mongoose

MongoDB: Sort UTF-8 strings


Use collation here with locale: "en"

With aggregation you can do something like this (mongodb)

Schedule.aggregate([{ "$sort": { "_id.name": 1 }}], { "collation": { "locale": "en" }})

With mongoose you can use collation inside your schema

var schema = new Schema({  name: String}, { collation: { locale: 'en' })Schedule.aggregate([{ "$sort": { "_id.name": 1 }}]).exec((error, response) => {  console.log(response)})