function groupArray(arr, keyfn, keyName, valueName) {
            keyName = keyName || 'key';
            valueName = valueName || 'values';
            var groupMap = {};
            var groupList = [];
            arr.forEach(function (o) {
                var key = keyfn(o);
                var group = groupMap[key];
                if (!group) {
                    group = {};
                    group[keyName] = key;
                    group[valueName] = [];
                    groupMap[key] = group;
                    groupList.push(group);
                }
                group[valueName].push(o);
            });
            return groupList;
        }
******************************************************
         // Group an array of objects by an object property. Each element of the returned array
         // is a object { keyName: key, valueName: [{...},...] }
         // arr: array of objects
         // keyfn: function to get the desired group key from each object
         // keyName: name of key property in resulting objects (defaults to 'key')
         // valueName: name of values property in resulting objects (defaults to 'values')
         // returns: array of key,values objects, where the values are objects from the original array.
         // See utilSpec.js for an example.
*******************************************************