Please read: I know this feels like the kind of question that's been answered ad nauseam on Stack Overflow, but I swear I can't find a good answer. Besides, marking this as "Possible duplicate" would be too meta!
I have a matrix of values in a particular order (in javascript):
[ [1,2], [1,2], [3,4], [5,6] [5,6] ]
However I recently learned that Google charts crashes when there are identical rows. I need to remove the duplicates; however, the array is fairly large and I can't afford the quadratic time of a naive implementation.
Normally, if the rows were each hashable, I'd add them to a dictionary { }
to see which I'd already seen; however, javascript does not allow arrays to be hashed.
What is the best approach? I guess I could convert the array for each row into a string and use that as the key, but that feels like a pretty dirty (and potentially slow) hack. I'd really love your advice.