Re: [Tutor] Python sort with a delimiter

2005-05-11 Thread Danny Yoo
On Wed, 11 May 2005, Tom Tucker wrote: > Good morning! Does Python have a sort function thats supports a delimiter? Hi Tom, Not directly, but it's actually not too difficult to get this working. Python's sort() function can take in an optional "comparison" function, so we can do something lik

Re: [Tutor] Python sort with a delimiter

2005-05-11 Thread Kent Johnson
A more direct approach is to write a helper function that extracts the desired data from a field, and use that as the sort key: hostnames = '''sys01-xxx-austin-tx sys02-xxx-austin-tx sys01-xxx-newark-oh sys01-yyy-newark-oh sys01-yyy-austin-tx sys01-zzz-newark-oh sys02-zzz-newark-oh'''.split() d

Re: [Tutor] Python sort with a delimiter

2005-05-11 Thread Tom Tucker
Interesting! Thank you! On 5/11/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Tom Tucker wrote: > > Good morning! Does Python have a sort function thats supports a delimiter? > > For example, I want to sort the below hostnames, based on the city. > > This is easy to do in Python but you have

Re: [Tutor] Python sort with a delimiter

2005-05-11 Thread Kent Johnson
Tom Tucker wrote: > Good morning! Does Python have a sort function thats supports a delimiter? > For example, I want to sort the below hostnames, based on the city. This is easy to do in Python but you have to break it up into a few steps - Python's sort doesn't know how to find fields but

[Tutor] Python sort with a delimiter

2005-05-11 Thread Tom Tucker
Good morning! Does Python have a sort function thats supports a delimiter? For example, I want to sort the below hostnames, based on the city. Thanks! Tom Hostnames to be sorted - sys01-xxx-austin-tx sys02-xxx-austin-tx sys01-yyy-austin-tx sys01-xxx-newa