10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-11-05 21:54:01 +01:00
QUESTDB_website/static/js/uniq.js

12 lines
349 B
JavaScript
Raw Normal View History

2019-09-28 15:22:17 +02:00
function uniq(array)
{
2020-11-19 23:12:14 +01:00
if (array.length == 0) return [];
2020-11-20 00:23:28 +01:00
const sortedArray = array.sort().map( x => [x, JSON.stringify(x)] );
2020-11-19 23:12:14 +01:00
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;
}