Thanks! Basically all I wanted was
Array.prototype.sort()
, but without the need to use the semi-cryptic apply()
. No escaping it without a plugin for the time being, I guess.
I have another issue, however; my view is not getting
updated:
- sortColumn: function(scope, element, event) {
- var comparator = scope.attr("key");
- var sorted = Array.prototype.sort.apply( this.attr("files"), [function(a,b) {
- a = a.attr("sloc").attr(comparator);
- b = b.attr("sloc").attr(comparator);
- if ( this.attr("ascending") ) {
- return a===b ? 0 : a<b ? -1 : 1;
- } else {
- return a===b ? 0 : a>b ? -1 : 1;
- }
- }.bind(this)]);
- this.attr("files", sorted);
- },