Hey all,
I am very new to python, and not usually a programmer. Have mercy, please :) I am comparing road address ranges to find inconsistencies . Some roads are much longer than others and are represented by many database records. Sucking the data into python, I have arranged it like this:
{CASTLERIDGE: [3281, 1000, 1099, 21553, 900, 999]}
{BROOKRIDGE: [3265, 1000, 1099, 3276, 1100, 1199, 16398, 1200, 1299]}
where the dictionary key is the road name, the value is a repeating sequence consisting of the database key, the low address range, and the high address range. CASTLERIDGE is out of sequence, and needs to be sorted by the second value (low address range) of each sequence. It should look like this:
{CASTLERIDGE: [21553, 900, 999, 3281, 1000, 1099]}
After I get the data sorted, I then plan to check if element[4] < element[2].
If true, then return element[0] and element[3] to a list of naughty members. Then, step to the next sequence and run the comparison again.
I would like suggestions on sorting the data by the second element of each sequence, but I am also open to restructuring my data to improve sort performance and/or comparison.
Many thanks,
Matt
I am very new to python, and not usually a programmer. Have mercy, please :) I am comparing road address ranges to find inconsistencies . Some roads are much longer than others and are represented by many database records. Sucking the data into python, I have arranged it like this:
{CASTLERIDGE: [3281, 1000, 1099, 21553, 900, 999]}
{BROOKRIDGE: [3265, 1000, 1099, 3276, 1100, 1199, 16398, 1200, 1299]}
where the dictionary key is the road name, the value is a repeating sequence consisting of the database key, the low address range, and the high address range. CASTLERIDGE is out of sequence, and needs to be sorted by the second value (low address range) of each sequence. It should look like this:
{CASTLERIDGE: [21553, 900, 999, 3281, 1000, 1099]}
After I get the data sorted, I then plan to check if element[4] < element[2].
If true, then return element[0] and element[3] to a list of naughty members. Then, step to the next sequence and run the comparison again.
I would like suggestions on sorting the data by the second element of each sequence, but I am also open to restructuring my data to improve sort performance and/or comparison.
Many thanks,
Matt
Comment