def stations_by_river(stations): 
    """Given a list of MonitoringStation objects, returns a dictionary with keys being river names
    and values being a sorted list of the names of the monitoring stations on that river"""

    ans = {}
    for station in stations: 
        if station.river not in ans: 
            ans[station.river] = [station.name]
        else: 
            ans[station.river].append(station.name)
    for key in ans: 
        ans[key].sort()
    return ans