def METHOD_NAME(data, order):
    new_data = bytearray()
    for r, g, b in struct.iter_unpack('BBB', data):
        for channel in order:
            if channel == "r":
                new_data.append(r)
            elif channel == "g":
                new_data.append(g)
            elif channel == "b":
                new_data.append(b)
            else:
                raise ValueError("Unknown channel {}".format(channel))
    return bytes(new_data)