I'm not quite sure what your asking, but you should be able to just add a attribute.
for example if you want to add a attribute called "test" and you want the value of test to be "ahh!" then you just do something like this:
layer.features[i].attributes.test = "ahh!";
it sounds like you may want to sort the features by a attribute (like that ID value) first, and then just loop through and add the attributes.
I haven't tried this yet but you should be able to sort features( depending on what WFS service you are using) by adding something like this :
&sortBy=PERSONS%20D
to the layer in the WFS call. this is saying sort by the attribute PERSONS (%20) just means space and the D means in descending order.
read more about sorting here
http://geo-solutions.blogspot.com/2011/12/wfs-for-masses-adding-support-for.htmlhope that helps,
-will