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