I have a google spreadsheet which contains the multiple data spread across various columns (like 6 columns - Phone number, IMEI, URL, Id, Reg No and Time) and i have 15K rows of data.
I have to find/show all the duplicate phone number(Column 0) and data associated with them in a new sheet.
However when i try to sort the data, it throws me error like
"Comparison method violates its general contract. (line 6, file "Code")"
The code is shown below for your reference:
function myFunction() {
var values = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('DUP').getDataRange().getValues()
var dupData = new Array();
values.sort(function sortFunction(a, b) {
if (a[0] === b[0]) {
return 0;
}
else {
return (a[0] < b[0]) ? -1 : 1;
}
});
for(i=1;i<values.length;i++)
{
if (values[i][0] == values[i+1][0]) {
dup.push(values[i]);
}
}
var new1 = dpnum.getSheetByName('Test123');
new1.getRange(1,1,dup.length,dup[0].length).setValues(dup);
}