function dataByGroupId(data) {
    var groups = [...new Set(data.sites.map(site => site.group))]
        .sort((a, b) => a.localeCompare(b));
    var result = {}
    groups.forEach(groupId => {
        result[groupId] = data.sites.filter(site => site.group === groupId)
            .sort((a, b) => a.name.localeCompare(b.name));
    });
    return result;
}
/**
 * Restructures the data to a map where the key is the groupIds and the value the list
 * of sites (sorted alphabetical) that belong to that group.
 */
Restructures the data to a map where the key is the groupIds and the value the list
of sites (sorted alphabetical) that belong to that group.
Restructures the data to a map where the key is the groupIds and the value the list of sites ( sorted alphabetical ) that belong to that group .
function dataByGroupId(data) {
    var groups = [...new Set(data.sites.map(site => site.group))]
        .sort((a, b) => a.localeCompare(b));
    var result = {}
    groups.forEach(groupId => {
        result[groupId] = data.sites.filter(site => site.group === groupId)
            .sort((a, b) => a.name.localeCompare(b.name));
    });
    return result;
}
function dataByGroupId ( data ) { var groups = [ ... new Set ( data . sites . map ( site => site . group ) ) ] . sort ( ( a , b ) => a . localeCompare ( b ) ) ; var result = { } groups . forEach ( groupId => { result [ groupId ] = data . sites . filter ( site => site . group === groupId ) . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ; } ) ; return result ; }
Restructures the data to a map where the key is the groupIds and the value the list
 of sites (sorted alphabetical) that belong to that group.
Restructures the data to a map where the key is the groupIds and the value the list of sites ( sorted alphabetical ) that belong to that group .