3
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..

1 Answers1

3

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

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/

Community
  • 1
  • 1
peter
  • 14,348
  • 9
  • 62
  • 96