private void listRemoteReplicas() {
    // Custom comparator to sort ReplicaId instances, such that those that are in Helix LEADER state appear first,
    // followed by STANDBY, followed by anything else.
    Comparator<ReplicaId> replicaIdComparator = (r1, r2) -> {
      if (getReplicaState(r1) == ReplicaState.LEADER && getReplicaState(r2) != ReplicaState.LEADER) {
        return -1;
      } else if (getReplicaState(r1) != ReplicaState.LEADER && getReplicaState(r2) == ReplicaState.LEADER) {
        return 1;
      } else if (getReplicaState(r1) == ReplicaState.STANDBY && getReplicaState(r2) != ReplicaState.STANDBY) {
        return -1;
      } else if (getReplicaState(r1) != ReplicaState.STANDBY && getReplicaState(r2) == ReplicaState.STANDBY) {
        return 1;
      }
      return 0;
    };

    // Sort the replicas in each remote data center such that LEADER replicas appear first, then STANDBY replicas.
    for(String dcName : remoteDatacenters) {
      Collections.sort(replicaPoolByDc.get(dcName), replicaIdComparator);
    }

    // While there are still replicas left in any remote colo, append remote replicas to the list in alternating colo
    // order.
    while(remoteReplicasLeft())
    {
      String nextDc = getNextRemoteDatacenter();
      if(!replicaPoolByDc.get(nextDc).isEmpty())
        remoteReplicas.addLast(replicaPoolByDc.get(nextDc).removeFirst());
    }
  }
Generate the list of remote replicas to send requests to. The list is ordered by Helix state as follows:
1. ReplicaIds in Helix LEADER state. Since Ambry replication happens between leaders in data centers, we prefer to
   prioritize sending requests to leaders first, in order to reduce replication traffic (if a blob is already
   present on a leader, we do not need to request it from another data center).
2. ReplicaIds in Helix STANDBY state.
3. All other ReplicaIds.
Note that the list of remote replicas is also ordered by alternating remote data centers. The intuition is that if
the first request to a remote data center fails, we attempt reaching a replica in a different data center instead
of retrying the same data center. A hypothetical example of such an ordered list, assuming that the remote colos
are prod-ltx1 and prod-lva1:
[prod-ltx1-LEADER, prod-lva1-LEADER, prod-ltx1-STANDBY, prod-lva1-STANDBY, prod-ltx1-STANDBY, prod-lva1-STANDBY]
ambry-router/src/main/java/com/github/ambry/router/ParanoidDurabilityOperationTracker.java