I have an array of 800 sentences. I want to remove all duplicates (sentences that have the same exact words, but in different order) from the array. So for example \"this is
How about this?
va = ["this is a sentence", "sentence this is", "sentence this is a"]
vb = {} // dictionary of combined sorted words in each sentence
vc = [] // output list of sentences without duplicates
for (i=0;i a is sentence this)
var combined = va[i].split(" ").sort().join(" ");
if (!vb[combined]){ // if set of combined sorted words doesn't exist already
vc.push(va[i]); // sentence isn't duplicated, push to output list
vb[combined] = true // add set to dictionary
}
}
alert(vc.join("\n"))