private void sortUp() {
        if (size > peaksize) {
            peaksize = size;
        }

        // determine the first array big enough to take them all
        int cnt = 8; // value count of first 2 bins is always 8
        SortedBin tbin = second; // target bin
        SortedBin lastNonEmpty = second;
        do {
            tbin = tbin.next();
            final int nentries = tbin.binsize - tbin.lp;
            if (nentries > 0) {
                cnt += nentries;
                lastNonEmpty = tbin;
            }
        }
        while (cnt > tbin.binsize);

        final int[] alT = tbin.al;
        final Object[] vlaT = tbin.vla;
        int tp = tbin.binsize - cnt; // target pointer

        // unlink any higher, non-empty arrays
        final SortedBin otherNonEmpty = lastNonEmpty.nextNonEmpty;
        lastNonEmpty.nextNonEmpty = null;

        // now merge the content of these non-empty bins into the target bin
        while (firstNonEmpty != null) {
            // copy current minimum to target array
            final SortedBin minBin = firstNonEmpty.getMinBin();
            alT[tp] = minBin.lv;
            vlaT[tp++] = minBin.dropLowest();
        }

        tp = tbin.binsize - cnt;
        tbin.lp = tp; // new target low pointer
        tbin.lv = tbin.al[tp];
        tbin.nextNonEmpty = otherNonEmpty;
        firstNonEmpty = tbin;
    }
add a key value pair to the heap

@param key   the key to insert
@param value the value to insert object
main/src/main/java/cgeo/geocaching/brouter/util/SortedHeap.java