def __init__(self, postgresql: 'Postgresql', cluster: Cluster) -> None:
        """Create :class:``_ReplicaList`` object.

        :param postgresql: reference to :class:``Postgresql`` object.
        :param cluster: currently known cluster state from DCS.
        """
        super().__init__()

        # We want to prioritize candidates based on `write_lsn``, ``flush_lsn``, or ``replay_lsn``.
        # Which column exactly to pick depends on the values of ``synchronous_commit`` GUC.
        sort_col = {
            'remote_apply': 'replay',
            'remote_write': 'write'
        }.get(postgresql.synchronous_commit(), 'flush') + '_lsn'

        members = CaseInsensitiveDict({m.name: m for m in cluster.members
                                       if m.is_running and not m.nosync and m.name.lower() != postgresql.name.lower()})
        replication = CaseInsensitiveDict({row['application_name']: row for row in postgresql.pg_stat_replication()
                                           if row[sort_col] is not None and row['application_name'] in members})
        for row in replication.values():
            member = members.get(row['application_name'])

            # We want to consider only rows from ``pg_stat_replication` that:
            # 1. are known to be streaming (write/flush/replay LSN are not NULL).
            # 2. can be mapped to a ``Member`` of the ``Cluster``:
            #   a. ``Member`` doesn't have ``nosync`` tag set;
            #   b. PostgreSQL on the member is known to be running and accepting client connections.
            #   c. ``Member`` isn't supposed to stream from another standby (``replicatefrom`` tag).
            if member and row[sort_col] is not None and not self._should_cascade(members, replication, member):
                self.append(_Replica(row['pid'], row['application_name'],
                                     row['sync_state'], row[sort_col],
                                     bool(member.nofailover), member.sync_priority))

        # Prefer replicas with higher ``sync_priority`` value, in state ``sync``,
        # and higher values of ``write``/``flush``/``replay`` LSN.
        self.sort(key=lambda r: (r.sync_priority, r.sync_state, r.lsn), reverse=True)

        # When checking ``maximum_lag_on_syncnode`` we want to compare with the most
        # up-to-date replica otherwise with cluster LSN if there is only one replica.
        self.max_lsn = max(self, key=lambda x: x.lsn).lsn if len(self) > 1 else postgresql.last_operation()
Create :class:``_ReplicaList`` object.

        :param postgresql: reference to :class:``Postgresql`` object.
        :param cluster: currently known cluster state from DCS.
        
patroni/postgresql/sync.py