code: private void initBuckets() {
          if (buckets != null) {
              return;
          }
          buckets = createBucketList();
          if (inputList == null || inputList.isEmpty()) {
              return;
          }
  
          // Sort the records by name.
          // Stable sort preserves input order of collation duplicates.
          Collections.sort(inputList, recordComparator);
  
          // Now, we traverse all of the input, which is now sorted.
          // If the item doesn't go in the current bucket, we find the next bucket that contains it.
          // This makes the process order n*log(n), since we just sort the list and then do a linear process.
          // However, if the user adds an item at a time and then gets the buckets, this isn't efficient, so
          // we need to improve it for that case.
  
          Iterator<Bucket<V>> bucketIterator = buckets.fullIterator();
          Bucket<V> currentBucket = bucketIterator.next();
          Bucket<V> nextBucket;
          String upperBoundary;
          if (bucketIterator.hasNext()) {
              nextBucket = bucketIterator.next();
              upperBoundary = nextBucket.lowerBoundary;
          } else {
              nextBucket = null;
              upperBoundary = null;
          }
          for (Record<V> r : inputList) {
              // if the current bucket isn't the right one, find the one that is
              // We have a special flag for the last bucket so that we don't look any further
              while (upperBoundary != null &&
                      collatorPrimaryOnly.compare(r.name, upperBoundary) >= 0) {
                  currentBucket = nextBucket;
                  // now reset the boundary that we compare against
                  if (bucketIterator.hasNext()) {
                      nextBucket = bucketIterator.next();
                      upperBoundary = nextBucket.lowerBoundary;
                  } else {
                      upperBoundary = null;
                  }
              }
              // now put the record into the bucket.
              Bucket<V> bucket = currentBucket;
              if (bucket.displayBucket != null) {
                  bucket = bucket.displayBucket;
              }
              if (bucket.records == null) {
                  bucket.records = new ArrayList<Record<V>>();
              }
              bucket.records.add(r);
          }
      }
docs: Creates an index, and buckets and sorts the list of records into the index.