how to turn a sorted list into tab delimited values in Python?
Question: I have a sorted list that looks like this [('100','abc'),('99','bca')]. I want
to turn this into something like this into a text file.

    
    
    abc     100<br>
    bca     99
    

I have tried this  

    
    
    import csv
    writer = csv.writer(f, delimiter = '\t')
    writer.writerows(d)
    

but this gives me the output as:

    
    
    100 abc<br>
    99  bca
    


Answer: Using the [csv module](http://docs.python.org/2/library/csv.html), this is
pretty straight-forward:

    
    
    import csv
    
    data = [('100','abc'),('99','bca')]
    
    # Use 'w' for other OS's than Windows
    with open('my_data.csv', 'wb') as ofile: 
        writer = csv.writer(ofile, delimiter='\t')
        for row in data:
            writer.writerow(list(reversed(row)))
    

**`my_data.csv`:**

    
    
    abc 100
    bca 99
    

