mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-12-27 23:04:08 +01:00
12 lines
367 B
JavaScript
12 lines
367 B
JavaScript
function uniq(array)
|
|
{
|
|
if (array.length == 0) return [];
|
|
const sortedArray = array.map( x => [JSON.stringify(x), x] ).sort();
|
|
var uniqueArray = [ sortedArray[0][1] ];
|
|
for (let i=1 ; i<sortedArray.length ; i++) {
|
|
if ( sortedArray[i][0].localeCompare(sortedArray[i-1][0]) != 0 )
|
|
uniqueArray.push(sortedArray[i][1])
|
|
}
|
|
return uniqueArray;
|
|
}
|