<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def load_grid_data(file_list, data_type="binary", sort=True, delim=" "):
 """ Loads data from one or multiple grid_task files. Arguments: file_list - either a string or a list of strings indicating files to load data from. Files are assumed to be in grid_task.dat format (space delimited values, one per cell). data_type - a string representing what type of data is in the file. Either "binary", "int", "float", or "string". sort - If you're making a movie, you want the files to be in chronological order. By default, they will be sorted. If for some reason you don't want them in chronological order, set sort to False. Returns: A three-dimensional array. The first dimension is columns, the second is rows. At each row,column index in the array is another list which holds the values that each of the requested files has at that location in the grid. If you want this list collapsed to a single representative number, you should use agg_niche_grid. """


    # If there's only one file, we pretend it's a list
    if not type(file_list) is list:
        file_list = [file_list]
    elif sort:
        # put file_list in chronological order
        file_list.sort(key=lambda f: int(re.sub("[^0-9]", "", f)))

    world_size = get_world_dimensions(file_list[0], delim)

    # Initialize empty data array
    data = initialize_grid(world_size, [])

    # Loop through file list, reading in data
    for f in file_list:
        infile = open(f)
        lines = infile.readlines()
        for i in range(world_size[1]):
            lines[i] = lines[i].strip().split(delim)

            for j in range(world_size[0]):
                if data_type == "binary":
                    val = bin(int(lines[i][j]))
                elif data_type == "float":
                    val = float(lines[i][j])
                elif data_type == "int":
                    val = int(lines[i][j])
                elif data_type == "string":
                    val = str(lines[i][j])
                else:
                    print("Unsupported data_type passed to load_grid")
                    return
                data[i][j].append(val)

        infile.close()

    return data