Case Insensitive Alphabetical Sorting in MongoDB Query

As the title says, is it possible to sort case INsensitive alphabetically in a mongo.find query?

For example, normally the alphabetical sort will default to this:

‘Aaa’
‘Bbb’
‘aaa’

I want it to do this however:

‘Aaa’
‘aaa’
‘Bbb’

The names are created by users, so I can’t control whether or not they are created with a capital letter or not.

Use collation on both the index and query: https://docs.mongodb.com/manual/core/index-case-insensitive/

Another option is to add another key in your document with converted values (all lowercase) that you can index normally without collation

This app was created with Meteor v. 1.9 and I am concerned about compatibility with other imports I have, so I haven’t updated and would prefer not to.
In 1.9, collection.createIndex() doesn’t exist.

Does this mean I have to go with the second option you suggested (lowercase key)?

I do notice a way to create an index on the cloud site where my DB is stored. Is an index aside from the default one even needed though?

Doing this didn’t work, so perhaps I do need an index:

SongList.find({userID:“Test User”}, {sort:{“songTitle”:1}}, {collation:{locale : ‘en’, strength: 2}}).fetch();

Also, for a frame of reference, the code I currently use to list the tracks is in a helper for a dropdown element:

var id = Session.get(‘username’);
var list = SongList.find({userID:id}, {sort:{“songTitle”:1}}).fetch();
return list;

Collation requires an index.

You can use Collection._ensureIndex()

Ok. I apologize but I’m still a little confused on how indexing and collation works.

I would like to fetch and display all the songs that match a userID (string).
I want to sort the songs by song title.

Let’s say I make an index with the field being songTitle, and collation options locale en, strength 2. (I was able to do this on the cloud where I store it, as I use Atlas).
Sure, the index will work if I specify the selector to be one of the songTitles, but I just want to find all the songTitles that match the selector userID:[current username], and sort by songTitles.
So how do I make it correspond to this current query that I use:

SongList.find({userID:“Test User”}, {sort:{“songTitle”:1}});

Use Underscore.js to _.sortBy - set all to lowercase so you don’t have no problems

e.g:

let sortedObj = _.sortBy(arrayObj, function(key){ return key.toLowerCase(); });