export function groupBy<A>(arr: A[], criteria: ((a: A) => string) | string) {
return arr.reduce(function (obj, item) {
var key = typeof criteria === "function" ? criteria(item) : item[criteria];
if (!obj.hasOwnProperty(key)) {
obj[key] = [];
}
obj[key].push(item);
return obj;
}, {});
}