I've written a very simple app that based on user input generates a configuration file. However the order in which the data is dumped from StringIO into the actual conf file matters for the program using the file. The way I've addressed this in my code was a top to bottom data input model. But if the user enters data out of order, this will cause the program to fail or the resulting conf file will become useless. Is there a way of re-conciliating random data input order and making sure that the data from StringIO is inserted in a specific order?

Currently the code looks like this (and it got to this stage with a lot of help from you guys!)

```
        self.output = StringIO.StringIO()     

    context = self.toolbar.get_style_context()
    context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)

def on_servername_activate(self, widget):
    output = StringIO.StringIO()         
    servername = widget.get_text()
    self.output.write("USHARE_NAME="+servername+'\n')

def on_netif_changed(self, widget):
    netif = widget.get_active_text()
    self.output.write("USHARE_IFACE="+netif+'\n')

def on_port_activate(self, widget):
    port = widget.get_text()
    self.output.write("USHARE_PORT="+port+'\n')

def on_telprt_activate(self, widget):
    telprt = widget.get_text()
    self.output.write("USHARE_TELNET_PORT="+telprt+'\n')

def on_dirs_activate(self, widget):
    dirs = widget.get_text()
    self.output.write("USHARE_DIR="+dirs+'\n')

def on_iconv_toggled(self, widget):
    iconv = widget.get_active()
    if iconv == True:
        self.output.write("USHARE_OVERRIDE_ICONV_ERR="+"True"+'\n')
    else:
        self.output.write("USHARE_OVERRIDE_ICONV_ERR="+"False"+'\n')

def on_webif_toggled(self, widget):
    webif = widget.get_active()
    if webif == True:
       self.output.write("USHARE_ENABLE_WEB="+"yes"+'\n')
    else:
       self.output.write("USHARE_ENABLE_WEB="+"no"+'\n')

def on_telif_toggled(self, widget):
    telif = widget.get_active()
    if telif == True:
        self.output.write("USHARE_ENABLE_TELNET="+"yes"+'\n')
    else:
        self.output.write("USHARE_ENABLE_TELNET="+"no"+'\n')

def on_xbox_toggled(self, widget):
    xbox = widget.get_active()
    if xbox == True:
        self.output.write("USHARE_ENABLE_XBOX="+"yes"+'\n')
    else:
        self.output.write("USHARE_ENABLE_XBOX="+"no"+'\n')

def on_dlna_toggled(self, widget):
    dlna = widget.get_active()
    if dlna == True:
        self.output.write("USHARE_ENABLE_DLNA="+"yes"+'\n')
    else:
        self.output.write("USHARE_ENABLE_DLNA="+"no"+'\n')

def on_commit_clicked(self, widget):
    commit = self.output.getvalue()
    logfile = open('/home/boywithaxe/Desktop/ushare.conf','w')
    logfile.write(commit)

def on_endprogram_clicked(self, widget):
    sys.exit(0)

```