Skip to content

Sort differs from ampersand-collection #20

@herregroen

Description

@herregroen

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;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions