{"action":"created","issue":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2387","labels_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2387/labels{/name}","comments_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2387/comments","events_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2387/events","html_url":"https://github.com/marionettejs/backbone.marionette/issues/2387","id":59411717,"number":2387,"title":"reorderOnSort: true only works once when reversing collection order","user":{"login":"bazineta","id":564060,"avatar_url":"https://avatars.githubusercontent.com/u/564060?v=3","gravatar_id":"","url":"https://api.github.com/users/bazineta","html_url":"https://github.com/bazineta","followers_url":"https://api.github.com/users/bazineta/followers","following_url":"https://api.github.com/users/bazineta/following{/other_user}","gists_url":"https://api.github.com/users/bazineta/gists{/gist_id}","starred_url":"https://api.github.com/users/bazineta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bazineta/subscriptions","organizations_url":"https://api.github.com/users/bazineta/orgs","repos_url":"https://api.github.com/users/bazineta/repos","events_url":"https://api.github.com/users/bazineta/events{/privacy}","received_events_url":"https://api.github.com/users/bazineta/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/labels/bug","name":"bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-01T18:47:52Z","updated_at":"2015-03-02T21:21:23Z","closed_at":null,"body":"When using\r\n```\r\nreorderOnSort: true\r\n```\r\nin a collection or composite view, the reordering will only work once when reversing the order of a collection.  Problem is here:\r\n\r\nhttps://github.com/marionettejs/backbone.marionette/blob/master/src/collection-view.js#L179\r\n\r\nBasically, this is running the list of models in the collection against the BabySitter's view of things.  The first time one changes the comparator such that the model order in the collection is reversed and sorts, we'll land here and the model order will be compared against the BabySitter's view of things.  They won't match, and so the view will be reordered.\r\n\r\nHowever, nothing in the BabySitter has changed at this point.  If we then change the comparator again, once again reversing the order and sorting, we're once again back here, but now the model order matches what the BabySitter regards as correct.  As a result, orderChanged will be undefined; so far as the BabySitter is concerned, the model order and the view order are identical, so there's nothing to do.\r\n\r\nThus, one can reverse the sort order of a collection once, but subsequently, the view will remain unchanged."},"comment":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/comments/76827047","html_url":"https://github.com/marionettejs/backbone.marionette/issues/2387#issuecomment-76827047","issue_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2387","id":76827047,"user":{"login":"jgerigmeyer","id":552316,"avatar_url":"https://avatars.githubusercontent.com/u/552316?v=3","gravatar_id":"","url":"https://api.github.com/users/jgerigmeyer","html_url":"https://github.com/jgerigmeyer","followers_url":"https://api.github.com/users/jgerigmeyer/followers","following_url":"https://api.github.com/users/jgerigmeyer/following{/other_user}","gists_url":"https://api.github.com/users/jgerigmeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/jgerigmeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgerigmeyer/subscriptions","organizations_url":"https://api.github.com/users/jgerigmeyer/orgs","repos_url":"https://api.github.com/users/jgerigmeyer/repos","events_url":"https://api.github.com/users/jgerigmeyer/events{/privacy}","received_events_url":"https://api.github.com/users/jgerigmeyer/received_events","type":"User","site_admin":false},"created_at":"2015-03-02T21:21:23Z","updated_at":"2015-03-02T21:21:23Z","body":"Just to clarify, this bug doesn't exist only when reversing the collection specifically. It's any time the collection returns to the original order."}}