Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform a sorting with case insensitive in the sails js framework? [duplicate]

model.find({city: city, sort: 'cityname ASC'}, function(err, cityList){});

the above code giving the correct sorting list but whenever the city is in both uppercase or lowercase like Coimbatore,bangalore,Chennai it gives the output as Chennai,Coimbatore,bangalore but i need the output as bangalore,Chennai, Coimbatore like that. Please help me to get the output as i wanted.. and advace thanking to you all..

like image 326
Murali Selvaraj Avatar asked Dec 03 '25 09:12

Murali Selvaraj


1 Answers

This is an error in MongoDB - AFAIk there isn't really a solution for it as of now

  • similar SO question: Mongo DB sorting With case insensitive
  • mongoDB JIRA issue: https://jira.mongodb.org/browse/SERVER-90

Update: A workaround I've found - store the strings a second time only upper or only lower case and sort by that property: http://futurestud.io/blog/case-insensitive-sorting-with-mongoose-and-mongodb/

like image 102
peter Avatar answered Dec 04 '25 23:12

peter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!