def time_sort(x,y,ids,dates):
    """
    sort x,y,ids by increasing dates 
    
    Args:
        x (np.array or scipy.sparse): shape (n_compounds, n_descriptors)
        y (np.array): shape (n_compounds, )
        ids (str list): shape (n_compounds, ) 
        dates (float list): assay timing as year.fraction, shape (n_compounds, )
    Returns:
        x (np.array or scipy.sparse): shape (n_compounds, n_descriptors)
        y (np.array): shape (n_compounds, )
        ids (str list): shape (n_compounds, ) 
        dates (float list): assay timing as year.fraction, shape (n_compounds, )
    """
    sortidx,dates=zip(*sorted(enumerate(dates),key=lambda p: p[1]))
    sortidx=list(sortidx)
    x=x[sortidx]
    y=y[sortidx]
    ids=[ids[i] for i in sortidx]
    dates=list(dates)
    return x,y,ids,dates