docs: public void compact(boolean freeExtraMem) {
  
          if(compacted) return;
          
          // sort items by index (not including junk >=top)
          LongDoubleSort.sortIndexAsc(idx, vals, top);
  
          // let add() remove duplicate entries
          int oldTop = top;
          top = 0;
          for(int i=0; i<oldTop; i++)
              add(idx[i], vals[i]);
  
          if(freeExtraMem) {
              idx = Arrays.copyOf(idx, top);
              vals = Arrays.copyOf(vals, top);
          }
  
          compacted = true;
      }