Skip to main content
. 2022 Oct 12;22(20):7731. doi: 10.3390/s22207731
Algorithm 2 Sorter
Input: PED: PED sample values that need to be sorted.
 Path: Candidate path corresponding to the sample.
 K: The number of samples to be retained after sorting.
Output: remPED: Reserved PED value.
 remPath: Corresponding candidate path.
1: Function First sorting(PED, Path)
2: PED is divided into 2n heaps according to the characteristics of pre-n2 bits, and the
 number of each heap num1(i) is calculated.
3: for i = 1 to 2n do
4:  if num1(i) > K then
5:   The num1 data(as PED2) and the paths(as Path2) are sorted for the second time;
6:  else if num1(i) < K then
7:   The num1 data and the paths as output, i = i + 1;
8:  else
9:   The num1 data and the paths as output;
10:  end if
11:  NEXT i
12: end for
13: Function second sorting(PED2, Path2)
14: PED2 is divided into 2n heaps according to the characteristics of rest-n2 bits, and the
   number of each heap num2(i) is calculated.
15: for i = 1 to 2n do
16:  if num2(i) < K then
17:   The num2 data and the paths as output, i = i + 1;
18:  else
19:  The num2 data and the paths as output;
20:  end if
21:  NEXT i
22: end for
23: return