Sorting things into bins
Sue Giller
sag at hydrosphere.com
Wed Dec 12 19:26:53 EST 2001
More information about the Python-list mailing list
Wed Dec 12 19:26:53 EST 2001
- Previous message (by thread): Sorting things into bins
- Next message (by thread): Sorting things into bins
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Is there a quick and simple way to sort a set of values (strings in this case) into a set of bins, based on a subset of the characters in the string? This is a very simplified, small version of what I want to do, but if I can solve this example, I think I can expand it to fix my problem. All strings would be same length. These strings are contained in a list. For example, a set of strings that look like numbers. There is a pattern to the strings, as they represent date:time values and they can't easily be converted to a number. ['0101', '0102', '0103', '0201', '0202', '0203] I might want to sort them into two bins which I will define from the list of string (bins are all values for first 2 chars in the strings): 01, 02, => then 01 contains '0101', '0102', '0103', and 02 contains 0201, 0202 and 0203 or I might want to sort them into three bins (bins are all values for second 2 chars in the strings): 01, 02, 03 => then 01 contains 0101 and 0201, and 02 contains 0102, 0202, and 03 contains 0103 and 0203 The real bins will be built from a longer string than 2 chars. For some reason, I think this should have an elegant solution in python, but I am too much a newbie to see it. Any suggestions? Thanks
- Previous message (by thread): Sorting things into bins
- Next message (by thread): Sorting things into bins
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list