<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_config(sensor_graph):
 """Extract the config variables from this sensor graph in ASCII format. Args: sensor_graph (SensorGraph):
 the sensor graph that we want to format Returns: str: The ascii output lines concatenated as a single string """


    cmdfile = CommandFile("Config Variables", "1.0")

    for slot in sorted(sensor_graph.config_database, key=lambda x: x.encode()):
        for conf_var, conf_def in sorted(sensor_graph.config_database[slot].items()):
            conf_type, conf_val = conf_def

            if conf_type == 'binary':
                conf_val = 'hex:' + hexlify(conf_val)

            cmdfile.add("set_variable", slot, conf_var, conf_type, conf_val)

    return cmdfile.dump()