![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
backbone-sortable-collection
Advanced tools
var TurtleCollection = Backbone.SortableCollection.extend({
// Comparators are named by the key in this object
comparators: {
initial: function (turtle) { return turtle.get('initial'); },
// shorthand for function (food) { return turtle.get('food'); },
food: 'getter',
age: 'getter',
weird: function (turtleA, turtleB) {
if (turtleA.get('initial') === 'M') {
return -1;
} else if (turtleB.get('initial') === 'M') {
return 1;
} else {
return 0;
}
}
},
// Sorts can be used to string comparators together for multi-sort
// Useful for specifying fallback comparators and default behavior
sorts: {
// Comparators can be called by name, prefixed with '!' if the order should be descending
weird: ['!weird', 'initial'],
// Also sorts can be called as a string if there is only one comparator
oldest: '!age'
// By default, sort only uses the comparator, so following line is redundant
// initial: ['initial']
},
defaultSort: 'initial'
});
var turtles = new TurtleCollection([
{ initial: 'L', food: 'rice', age: 15.8 },
{ initial: 'R', food: 'cereal', age: 15.7 },
{ initial: 'D', food: 'pizza', age: 15.5 },
{ initial: 'M', food: 'pizza', age: 15.3 }
]);
// Default sort is active
console.log(turtles.pluck('initial')); // ['D', 'L', 'M', 'R']
// Single sort
turtles.changeSort('food');
console.log(turtles.pluck('initial')); // ['R', 'D', 'M', 'L']
// Bi-directional multi-sort
turtles.changeSort('weird');
// turtles.changeSort(['!weird', 'initial']); would achieve same result
console.log(turtles.pluck('initial')); // ['D', 'L', 'R', 'M']
// Fires sort event
turtes.on('sort', function () { console.log('Sorting!'); });
turtles.changeSort('initial'); // Sorting!
// Reverse sort (also fires sort event)
turtles.reverseSort(); // Sorting!
console.log(turtles.pluck('initial')); // ['M', 'R', 'L', 'D']
# Node
npm install backbone-sortable-collection --save
# Bower
bower install backbone-sortable-collection
FAQs
Add sorting functionalites to Backbone Collections
We found that backbone-sortable-collection demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.