def compare_internal_file_order(files: list):
    """
    This function will check whether the passed files are in the same order.
    This is done by comparing first the lengths of the files, and then the first
    element of each line of each file. This first element contains the filename
    corresponding to the vehicle that the data of this line belongs to.

    If a check fails, an assertion error is thrown.
    """

    def list_equal(somelist: list) -> bool:
        return all(somelist[0] == x for x in somelist)

    data = []
    for file in files:
        with open(file, "r") as f:
            data.append([line.split(",")[0] for line in f.readlines()])

    lengths = [len(datai) for datai in data]
    assert(list_equal(lengths)), f"input files {files} have different lengths: {lengths}."

    for i in range(len(data[0])):
        assert(list_equal([data[j][i] for j in range(len(data))])), f"mismatch found at line {i+1} in files {files}"