you don't need loops inside each other, just two sequential for loops you could have another array you store results in (to sort) or just print them out in order
you could make the second array a temporary item, remove items from the second array that are found in the first, then the second loop will not have to exist If splice is too expensive just set the items found in the second array to false, anything that's not false is not found in the first array. it will still not perform phenomenally, you would have better luck using a database with indices, you could do it in a query. I don't know of any trick way in JavaScript to create your own index so that the search starts at the correct offset in the list of indices, it's probably JS platform specific so you may get good performance in certain browsers. On Thu, Sep 29, 2011 at 1:46 PM, Robert <[email protected]> wrote: > ** > Hi, > > sorry, it may be a bit off topic. But I hope someone can help me with a > small problem. > > I have two lists that I want to compare for differences between. Both lists > have some thousands of already sorted entries. I colud solve it using two > for-loops inside each other. For small lists this is ok. But not for so many > values. > > Both lists are structured like this an only the keys should be compared (is > there a new key or one missing?): > > a1['jimmy'] = { name : 'Jim', ... } > a1['johndoe'] = { name : 'John', ... } > a1['robert'] = { name : 'Robert', ... } > > a2['chris'] = { name : 'Christian', ... } > a2['johndoe'] = { name : 'John', ... } > a2['robert'] = { name : 'Robert', ... } > a2['will'] = { name : 'William', ... } > > Now I just need the differend keys (new/missing) compared a1 to a2. > > The solutions I found seem to be to complex for my case. I need a simple an > effcient way to get the differences. > > > Might someone help me? > > > Tnx in advance, > Robert > > > > > -- > You received this message because you are subscribed to the Google Groups > "greasemonkey-users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/greasemonkey-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "greasemonkey-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en.
