def pad_list(listA, val=-1, length=None):
    """Pad list of lists with 'val' such that all lists have the same length.

    Parameters
    ----------
    listA : list
        List of lists of different sizes.
    val : number, optional
        Value to pad the lists.
    length : number, optional
        Total length of the list.

    Returns
    -------
    list
        A list of lists with the same same.

    Examples
    --------
    Pad an uneven list of lists with a value.

    >>> from dbcollection.utils.pad import pad_list
    >>> pad_list([[0,1,2,3],[45,6],[7,8],[9]])  # pad with -1 (default)
    [[0, 1, 2, 3], [4, 5, 6, -1], [7, 8, -1, -1], [9-1, -1, -1]]
    >>> pad_list([[1,2],[3,4]])  # does nothing
    [[1, 2], [3, 4]]
    >>> pad_list([[],[1],[3,4,5]], 0)  # pad lists with 0
    [[0, 0, 0], [1, 0, 0], [3, 4, 5]]
    >>> pad_list([[],[1],[3,4,5]], 0, 6)  # pad lists with 0 of size 6
    [[0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [3, 4, 5, 0, 0, 0]]

    """
    # pad list with zeros in order to have all lists of the same size
    assert isinstance(listA, list), 'Input must be a list. Got {}, expected {}' \
                                    .format(type(listA), type(list))

    # get size of the biggest list
    if length:
        max_size = length
    else:
        max_size = len(max(listA, key=len))

    # pad all lists with the a padding value
    return [l + [val] * int(max_size - len(l)) for l in listA]