code: function sortUnique(a) {
    var n=a.length;
    if (n<=1) return a;
    //do a shell sort
    var k=1,hi=n/3|0,i,j,tmp;
    while (k < hi) k=k*3+1;
    while (k > 0) {
      for (i=k;i<n;i++) {
        for (j=i;j>=k && a[j]<a[j-k];j-=k) {
          tmp=a[j]; a[j]=a[j-k]; a[j-k]=tmp;
        }
      }
      k=k/3|0;
    }
  
    var last=a[0],x;
    for (i=1,j=1;i<n;i++) {
      x=a[i];
      if (x===last) continue;
      last=a[j++]=a[i];
    }
    a.length=j;
    return a.length===j?a:copyArray(a,j); //Typed Array length property only has a getter
  }
docs: Return sorted Set.
  This function will corrupt the original array
  Proper usage: a=sortUnique(a);
  @param {ArrayLike} a
  @return {ArrayLike} new unique sorted array