So it seems that this function is where the attention should be focused on. Right?
var newData = $A();
var newHash = $H();
newData = newData.flatten().uniq().compact();
Were you aware that objects like Hash sets, cannot guarantee to maintain the relative ordering of its objects?
From the Quirksmode - Associative page.