## Appendix B Sort II Error Analysis
Therefore, the \(n-d\) last symbols (bits) of \(\mathbf{c}_{i}\) and \(\mathbf{c}_{j}\) are identical. Observe that the event \(\Big{\{}d_{\text{H}}(\mathbf{Y}(i),\mathbf{c}_{i})\leq\Big{\lfloor}n\delta_{ \beta}\Big{\rfloor}\Big{\}}\) implies that the received vector \(\mathbf{y}\) and \(\mathbf{c}_{i}\) differ in \(p\) bits, where \(p\leq\Big{\lfloor}n\delta_{\beta}\Big{\rfloor}\), i.e.,  
\[\mathcal{F}_{\delta_{\beta}}(i,j) \triangleq\bigg{\{}\mathbf{Y}\in\mathbf{H}^{n}\text{ ; }d_{\text{H}}(\mathbf{Y}(i),\mathbf{c}_{j})\leq\Big{\lfloor}n\delta_{\beta} \Big{\rfloor}\bigg{\}}. \tag{17}\]0  
Now, we assume that \(p_{1}\) bits out of the \(p\) bits happen in the first \(d\) bits, i.e., \(d_{\text{H}}(\mathbf{y}_{1}^{|d},\mathbf{c}_{i}|_{1}^{d})\)\(=p_{1}\), where  
\[\mathcal{F}_{\delta_{\beta}}(i,j) \triangleq\bigg{\{}\mathbf{Y}\in\mathbf{H}^{n}\text{ ; }d_{\text{H}}(\mathbf{Y}(i),\mathbf{c}_{j})\leq\Big{\lfloor}n\delta_{\beta} \Big{\rfloor}\bigg{\}}. \tag{17}\]1  
and \(p_{2}\) bits with \(p_{2}=p-p_{1}\) happens in last \(n-d\) bits, i.e., \(d_{\text{H}}(\mathbf{y}_{d+1}^{|n},\mathbf{c}_{i}|_{d+1}^{|n})=p_{2}\), where  
\[\mathcal{F}_{\delta_{\beta}}(i,j) \triangleq\bigg{\{}\mathbf{Y}\in\mathbf{H}^{n}\text{ ; }d_{\text{H}}(\mathbf{Y}(i),\mathbf{c}_{j})\leq\Big{\lfloor}n\delta_{\beta} \Big{\rfloor}\bigg{\}}. \tag{17}\]2Observe that since the symbols of sequences are bits, i.e., either \(0\) or \(1\); therefore, \(d=d_{\rm H}(\mathbf{c}_{i},\mathbf{c}_{j})\) implies that the two sequences \(\mathbf{c}_{i}\) and \(\mathbf{c}_{j}\) are complementary for the first \(d\) bits. Now, we infer that if the two sequences \(\mathbf{y}|_{1}^{d}\) and \(\mathbf{c}_{i}|_{1}^{d}\) differ in \(p_{1}\), then \(\mathbf{y}|_{1}^{d}\) and \(\mathbf{c}_{i}|_{1}^{d}\) are identical in those \(p_{1}\) bits. Hence, \(d_{\rm H}(\mathbf{y}|_{1}^{d},\mathbf{c}_{j}|_{1}^{d})=d-p_{1}\). Now, if we collect all the positions for which \(\mathbf{y}|_{1}^{n}\) and \(\mathbf{c}_{j}|_{1}^{n}\) differ, we obtain  
\[\mathcal{F}_{\delta_{\beta}}(i,j) \triangleq\bigg{\{}\mathbf{Y}\in\mathbf{H}^{n}\text{ ; }d_{\text{H}}(\mathbf{Y}(i),\mathbf{c}_{j})\leq\Big{\lfloor}n\delta_{\beta} \Big{\rfloor}\bigg{\}}. \tag{17}\]3  
Observe that, since we restrict ourselves to the event  
\[\mathcal{F}_{\delta_{\beta}}(i,j) \triangleq\bigg{\{}\mathbf{Y}\in\mathbf{H}^{n}\text{ ; }d_{\text{H}}(\mathbf{Y}(i),\mathbf{c}_{j})\leq\Big{\lfloor}n\delta_{\beta} \Big{\rfloor}\bigg{\}}. \tag{17}\]4  
\[\mathcal{F}_{\delta_{\beta}}(i,j) \triangleq\bigg{\{}\mathbf{Y}\in\mathbf{H}^{n}\text{ ; }d_{\text{H}}(\mathbf{Y}(i),\mathbf{c}_{j})\leq\Big{\lfloor}n\delta_{\beta} \Big{\rfloor}\bigg{\}}. \tag{17}\]5  
On the other hand, since \(d_{\rm H}(\mathbf{y},\mathbf{c}_{j})\leq\Big{\lfloor}n\delta_{\beta}\Big{\rfloor}\), we obtain  
\[\mathcal{F}_{\delta_{\beta}}(i,j) \triangleq\bigg{\{}\mathbf{Y}\in\mathbf{H}^{n}\text{ ; }d_{\text{H}}(\mathbf{Y}(i),\mathbf{c}_{j})\leq\Big{\lfloor}n\delta_{\beta} \Big{\rfloor}\bigg{\}}. \tag{17}\]6  
Now, in order to calculate \(\Pr\Big{(}d_{\rm H}(\mathbf{Y}(i),\mathbf{c}_{j})\leq\Big{\lfloor}n\delta_{ \beta}\Big{\rfloor}\Big{)}\) in (100), we first fix \(p_{1}\), and then sum up over all possible cases for the \(p_{2}\), then we would have a second sum which runs for values of \(p_{1}\) from \(0\) to \(d\). Observe that the \(p_{2}\) has two upper bounds given in (103) and (104); therefore, in the calculation, we restrict ourselves to the minimum of those two upper bounds. Let define \(p_{2}^{\rm UB}\triangleq\min\Big{\{}\left\lfloor n\delta_{\beta}\right\rfloor- p_{1},\Big{\lfloor}n\delta_{\beta}\Big{\rfloor}-d+p_{1}\Big{\}}\).