def METHOD_NAME(org_type):
    """
    Return a "row grouper" function which will group the rows of a practice
    level matrix by the supplied `org_type`
    Note that the function is memoized so that if org relationships are changed
    in the database then the application will need to be restarted to see the
    changes.
    """
    # Get the mapping from practice codes to IDs of groups
    if org_type == "practice":
        mapping = _practice_to_practice_map()
    elif org_type == "standard_practice":
        mapping = _practice_to_standard_practice_map()
    elif org_type == "ccg":
        mapping = _practice_to_ccg_map()
    elif org_type == "standard_ccg":
        mapping = _standard_practice_to_ccg_map()
    elif org_type == "pcn":
        mapping = _practice_to_pcn_map()
    elif org_type == "stp":
        mapping = _practice_to_stp_map()
    elif org_type == "regional_team":
        mapping = _practice_to_regional_team_map()
    elif org_type == "all_practices":
        mapping = _group_all(_practice_to_practice_map())
    elif org_type == "all_standard_practices":
        mapping = _group_all(_practice_to_standard_practice_map())
    else:
        raise ValueError("Unhandled org_type: " + org_type)
    return RowGrouper(
        (offset, mapping[practice_code])
        for practice_code, offset in get_db().practice_offsets.items()
        if practice_code in mapping
    )