static FeatureSort newInMemory() {
    List<SortableFeature> list = Collections.synchronizedList(new ArrayList<>());
    return new FeatureSort() {
      @Override
      public void sort() {
        list.sort(Comparator.naturalOrder());
      }

      @Override
      public long numFeaturesWritten() {
        return list.size();
      }

      @Override
      public CloseableConsumer<SortableFeature> writerForThread() {
        return list::add;
      }

      @Override
      public long estimateMemoryUsageBytes() {
        return 0;
      }

      @Override
      public long diskUsageBytes() {
        return 0;
      }

      @Override
      public Iterator<SortableFeature> iterator() {
        return list.iterator();
      }

      @Override
      public Iterator<SortableFeature> iterator(int shard, int shards) {
        if (shard < 0 || shard >= shards) {
          throw new IllegalArgumentException("Bad shard params: shard=%d shards=%d".formatted(shard, shards));
        }
        return IntStream.range(0, list.size())
          .filter(d -> d % shards == shard)
          .mapToObj(list::get)
          .iterator();
      }

      @Override
      public int chunksToRead() {
        return list.size();
      }
    };
  }
Returns a feature sorter that sorts all features in memory. Suitable for toy examples (unit tests).
planetiler-core/src/main/java/com/onthegomap/planetiler/collection/FeatureSort.java