def order_columns(output_df, census_cols):
    """Orders the columns according to required csv format
    Parameters
    ----------
    output_df : DataFrame
        Dataframe containing all output columns
        
    census_cols : list
        list containing all census variable names to keep in output, defined in config.json
        
    
    Returns
    -------
    list
        list of ordered columns
    """
    ordered_columns = []
    # geo columns
    ordered_columns.extend([
        'county_GEOID', 'census_tract_GEOID', 'bloc-group-code', 'county',
        'state'
    ])

    #eviction columns
    ordered_columns.extend(
        [col for col in output_df.columns if 'tract-avg-eviction' in col])
    ordered_columns.extend(
        [col for col in output_df.columns if col.startswith('eviction-rate')])
    ordered_columns.extend([
        col for col in output_df.columns if col.startswith('total-evictions')
    ])

    #foreclosure columns
    ordered_columns.extend(
        [col for col in output_df.columns if 'tract-avg-foreclosure' in col])
    ordered_columns.extend([
        col for col in output_df.columns if col.startswith('foreclosure-rate')
    ])
    ordered_columns.extend([
        col for col in output_df.columns if col.startswith('foreclosure-sales')
    ])

    # lien foreclosure
    ordered_columns.extend(
        [col for col in output_df.columns if 'lien-foreclosure-rate-' in col])
    ordered_columns.extend([
        col for col in output_df.columns
        if col.startswith('lien-foreclosures-')
    ])

    #housing loss
    ordered_columns.extend(
        [col for col in output_df.columns if 'avg-housing-loss-rate' in col])
    ordered_columns.extend(
        [col for col in output_df.columns if 'housing-loss-index' in col])
    ordered_columns.extend(
        ["ratio-to-mean-eviction-rate", "ratio-to-mean-foreclosure-rate"])

    #census
    ordered_columns.extend(census_cols)

    return output_df[[
        col for col in ordered_columns if col in output_df.columns
    ]]