ember.js: computed.sort works incorrectly with empty sort properties array

Problem: computed.sortmay do some “sorting” even if there aren’t properties to sort. Demo: https://ember-twiddle.com/83ed55ef7169c8dacefe?openFiles=application.controller.js%2C (see second column) Possible solution: Check if normalizedSortProperties is empty, don’t do any sorting (https://github.com/emberjs/ember.js/blob/v2.4.1/packages/ember-runtime/lib/computed/reduce_computed_macros.js#L670)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (16 by maintainers)

Most upvoted comments

I confirm the inconstant behaviour, here is another example to showcase the issue

https://ember-twiddle.com/4a1d8e3aa1bef71dd657431fd59cb445

it seems that array listeners are only set when sort properties array is not empty.

Like I said, I’m fine with this being something we decide to support. It should be covered with explicit tests and documented so I can’t get confused in the future. 😸