def get_columns(state):
    """Gets the columns of the display table.
    
    This function takes a filter state and returns an array of column names that are
    ordered depending on the position attribute of the columns. This order is important 
    as the queryset will be rendered in the display table according to the column order
    in this returned array.
    
    Parameters
    ----------
    state : FilterState
        Filter state of the columns.
        
    Returns
    -------
    List
        A list that dictates the order of the columns.

    """
    a=[]
    b=[]
    c=[]
    cols = state.filtercolumn_set.all()
    for col in cols:
        if col.visible == True:
            b.append(col.position)
            c.append(col.name)
    for i in range(0,len(b)):
        k = -1
        index = 0
        for j,val in enumerate(b):
            if val>k:
                k=val
                index = j
        a.append(c.pop(index))
        b.pop(index)
        a=a[::-1] # reverses the array

    return a