code: public int compareTo(Shard other) {
      // compare version
      if (version < other.version) {
        return -1;
      } else if (version > other.version) {
        return 1;
      }
      // compare dir
      int result = dir.compareTo(other.dir);
      if (result != 0) {
        return result;
      }
      // compare gen
      if (gen < other.gen) {
        return -1;
      } else if (gen == other.gen) {
        return 0;
      } else {
        return 1;
      }
    }
docs: Compare to another shard.
  @param other  another shard
  @return compare version first, then directory and finally generation