This is the final step to some complicated data sorting - so as an example lets say I have the following data:
indexequipmentNamesequenceequipCount1a102b103c204b215c316d307d418b429b5310e5011b6412e6113b7514f70
The goal is to get data ordered like this: abbccdd... etc. This works by sorting the sequence column ascending and the equipCount column (unique counter of equipment name) descending. The problem is that if there is a sequence pair that does not contain a zero (both pieces of equipment have appeared before) then its no longer beneficial to sort equipCount descending, instead it needs to be sorted ascending(see index 7 and 8 sequence pair 4, they should not reverse order 2 to 1; and index 11 and 12 sequence pair 6, they should reverse order to be 1 to 4). Again this is all to get the final order to be abbccddbbeebbf. My solution to this was to check if each equipCount value in a sequence pair was not zero, and then to make even numbers = 0, because an even unique count means it is the first of a new equipment pair and needs to come at the end of a sequence pair, the reverse being true for odd numbers - they need to come at the beginning of a sequence pair because they are rounding out an equipment pair. I am trying to accomplish this with a python caller, but I either can't get the syntax right, or do not know how to iterate and index through an attribute of a feature (compare row index 7 equipment count to row index 8 equipment count) in a for loop.
The following sudo-code will produce the result... but I am struggling with implementation
for rows (i) in table
if sequence(i) == sequence (i+1)
if equipCount(i) * equipCount(i+1) != 0
if modulus 2 of equipCount(i) == 0
equipCount(i) = 0
elif modulus 2 of equipCount(i+1) == 0
equipCount(i+1) = 0
I am also open to doing this kind of comparison and conditional attribute calculation without a python caller... but couldn't think of anything clever.
Thanks in advance.