Fixed some sort() functions, added a groupby function
This commit is contained in:
@@ -46,6 +46,18 @@ if (!String.prototype.repeat) {
|
||||
};
|
||||
}
|
||||
|
||||
// Group By
|
||||
if (!Array.prototype.groupby) {
|
||||
Array.prototype.groupby = function(prop) {
|
||||
return this.reduce(function(groups, item) {
|
||||
const val = item[prop]
|
||||
groups[val] = groups[val] || []
|
||||
groups[val].push(item)
|
||||
return groups
|
||||
}, {})
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert ANSI into BIN for loading into a Frame
|
||||
*
|
||||
@@ -70,10 +82,6 @@ function ans2bin(ansi,frame) {
|
||||
}
|
||||
}
|
||||
|
||||
function compare(a,b) {
|
||||
return (a.prefix < b.prefix) ? 1 : ((b.prefix < a.prefix) ? -1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a message base by code
|
||||
*
|
||||
@@ -162,7 +170,7 @@ function getPageOwners() {
|
||||
f.close();
|
||||
|
||||
// Sort the pageowners ascending
|
||||
pageowners.sort(compare);
|
||||
pageowners.sort(function(a,b) { return (a.prefix < b.prefix) ? 1 : ((b.prefix < a.prefix) ? -1 : 0); });
|
||||
|
||||
//log(LOG_DEBUG,'+ pageOwner: pageowners='+JSON.stringify(pageowners));
|
||||
}
|
||||
|
@@ -120,7 +120,7 @@ function MsgArea() {
|
||||
}
|
||||
}
|
||||
|
||||
return this.untagged_list.sort(function(x) { return x.when_written_time-(x.when_written_zone_offset*60); });
|
||||
return this.untagged_list;
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user