Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort differs from ampersand-collection #20

Open
herregroen opened this issue Jun 9, 2015 · 2 comments
Open

Sort differs from ampersand-collection #20

herregroen opened this issue Jun 9, 2015 · 2 comments

Comments

@herregroen
Copy link

The sort functions used by this package and ampersand-collection are not equivalent.

Ampersand-collection uses it's own method while here lodash.sortby is used. I'm getting different results.

Overwriting _sortModels to use the following fixes the issue:

bind = require('lodash.bind');

...

    _sortModels: function (newModels) {
        if (this.comparator) {
            newModels.sort(bind(this.comparator, this));
        } else if (this.collection.comparator {
            newModels.sort(bind(this.collection.comparator, this.collection));
        } else {
            // This only happens when parent got a .set with options.at defined
            this._runFilters();
        }
        return newModels;
    }
@wraithgar
Copy link
Contributor

The code in ampersand-collection is a custom build and is in need of swapping out for the lodash version, There's an issue in that repo for it here AmpersandJS/ampersand-collection#59

@jrmyio
Copy link

jrmyio commented Jul 4, 2015

I am also getting wierd values with this version. I used a function with a single argument to return a value for the item to be sorted on, but that gave broken results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants