sorting strings written to files

William Park opengeometry at yahoo.ca
Wed Apr 9 09:35:54 CEST 2003


onefatman <member27857 at dbforums.com> wrote:
> 
> Can someone help me?
> 
> I have a small phone directory .dat file that has the entries
> written to it as strings with three fields in each, separated by \t
> and ended by \n.
> 
> e.g.
> phbook.write("Joe\tNobody\t62907243\n")
> phbook.write("Daniel\tStevens\t62962328\n")
> phbook.write("Ellen\tWay\t62910758\n")
> phbook.write("Jason\tGreig\t62314587\n")
> 
> it has a function that allows you to write new entries, but i need to
> know how to sort them by first name, and then by last name when the
> first names are the same.

If it's already written to file, then 
    man sort
If it's still in Python, then
    list.sort()

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
Linux solution for data management and processing. 




More information about the Python-list mailing list