Using custom sort with Ember.computed.sort

Hi newbie here. I’m using Ember.computed.sort and was wondering how to properly use a custom function to sort a model property that is ‘belongsTo’. I managed to make it work by doing: sortDefinition: [‘supervisor.name:asc’]. Anyone know how to do it using a custom function? Screenshot below is what I’m currently working with, but it doesn’t work. I hope my question makes sense. Thanks in advance.

Are these ember-data models you’re dealing with? Is supervisor a relationship? If yes, then that is probably the problem – a.supervisor.name isn’t necessarily available synchronously. Also in that case, you probably need to use get.

Hey thanks for the reply. Yes these are ember-data models and supervisor is a relationship. If I was to use get would it look something like: a.get(“supervisor”).get(“name”) or a.get(“supervisor.name”) or a.get(“supervisor”).name?

I’d most likely use the middle one (a.get('supervisor.name')) but the first one would also work.

I think the larger issue though is if supervisor is available synchronously…

I figured it out. Thanks for the reply, I appreciate it :slight_smile: .