<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _idx_col_by_num(table):
 """ Index columns by number instead of by name. Use "number" key in column to maintain order :param dict table: Metadata :return list _table: Metadata """

    _columns = []
    try:
        # Create an empty list that matches the length of the column dictionary
        _columns = [None for i in range(0, len(table["columns"]))]

        # Loop and start placing data in the output list based on its "number" entry
        for _name, _dat in table["columns"].items():
            try:
                # Special case for ensemble table "numbers" list
                if isinstance(_dat["number"], list):
                    _columns.append(_dat)
                # Place at list index based on its column number
                else:
                    # cast number to int, just in case it's stored as a string.
                    n = int(_dat["number"])
                    _columns[n - 1] = _dat
            except KeyError as ke:
                print("Error: idx_col_by_num: {}".format(ke))
                logger_jsons.error("idx_col_by_num: KeyError: missing number key: {}, {}".format(_name, ke))
            except Exception as e:
                print("Error: idx_col_by_num: {}".format(e))
                logger_jsons.error("idx_col_by_num: Exception: {}".format(e))

        table["columns"] = _columns
    except Exception as e:
        logger_jsons.error("idx_col_by_num: {}".format(e))
        print("Error: idx_col_by_num: {}".format(e))

    return table