我在运行时在我的骨干集合上设置和取消设置比较器函数,我想知道是否有办法将集合“重置”为其原始插入顺序。例如...
var Mod = Backbone.Model.extend({});
var Col = Backbone.Collection.extend({ model: Mod });
var col = new Col([
    { name: "andy" },
    { name: "chad" },
    { name: "ashley" },
    { name: "louis" }
]);
col.comparator = function(p1, p2) {
    return p1.get('name') < p2.get('name') ? -1
        : (p1.get('name') > p2.get('name') ? 1 : 0 );
}
col.sort();
col.comparator = false;
// throws, was hoping this would return 
// the collection to insertion order
col.sort();
请忽略我在此处设置的比较器功能可以替换为sortBy实现的事实。这只是一个人为的例子。从 Backbone 源代码中我很清楚,如果您尝试对没有比较器的集合进行排序,它将抛出:
// ... from BB source ...
sort: function(options) {
    if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
    // ...
有没有办法将集合的顺序返回到插入顺序?