def sort(path, dt):
    df = pd.read_csv(path)
    if (path[(- 11):] == '_sorted.csv'):
        path_sorted = path
    else:
        path_sorted = (path[:(- 4)] + '_sorted.csv')
    df = df.sort_values(by=['time'], ascending=True)
    try:
        df.insert(loc=0, column='date-time', value=pd.to_datetime(df['time'], unit='ms'))
    except ValueError:
        raise ValueError('Data appears to have already been sorted. Check if still appropriate and add _sorted.csv tag to avoid this error.')
    df = df.set_index('date-time').resample((str(dt) + 's')).mean().round(2)
    df['time'] = ((df.index - pd.Timestamp('1970-01-01')) // pd.Timedelta('1s'))
    df = df.tz_localize('Europe/London')
    df = df.interpolate().round(2)
    df.to_csv(path_sorted, index=True)
def sort(path, dt):
    df = pd.read_csv(path)
    if (path[(- 11):] == '_sorted.csv'):
        path_sorted = path
    else:
        path_sorted = (path[:(- 4)] + '_sorted.csv')
    df = df.sort_values(by=['time'], ascending=True)
    try:
        df.insert(loc=0, column='date-time', value=pd.to_datetime(df['time'], unit='ms'))
    except ValueError:
        raise ValueError('Data appears to have already been sorted. Check if still appropriate and add _sorted.csv tag to avoid this error.')
    df = df.set_index('date-time').resample((str(dt) + 's')).mean().round(2)
    df['time'] = ((df.index - pd.Timestamp('1970-01-01')) // pd.Timedelta('1s'))
    df = df.tz_localize('Europe/London')
    df = df.interpolate().round(2)
    df.to_csv(path_sorted, index=True)