5 Applied Instructions and Basic Usage
DVP-20PM Application Manual
5-79
API
Applicable model
20PM
69
D
D
SORT
Sorting data
Bit device Word device
X Y M S K H KnX KnY KnM KnS T C D V Z
S
*
m1
* *
m2
* *
D
*
N
* *
*
Note: All devices can not be modified by V devices and Z devices.
Please refer to specifications for more information about device
ranges.
16-bit instruction (9 steps)
SORT
Continuity
instruction
-
32-bit instruction (17 steps)
DSORT
Continuity
instruction
-
Flag: None
Explanation
S: Initial device in which original data is stored; m
1
: Number of rows of data (m
1
=1~32); m
2
: Number of columns of data (m
2
=1~6); D: Initial device in which a
sorting result is stored; n: Reference value (n=1~m2) (Data is sorted in
algebraic order.)
The data which is sorted is stored in the m
1
×m
2
registers starting from the
register specified by D. If S and D specify the same register, the sorting result
gotten will be the same as the original data in the register specified by S.
It is better that the rightmost number of the device number of the register
specified by S is 0.
After the instruction is scanned m
1
times, the sorting of data will be complete.
After the sorting of data is complete, M1029 will be ON.
The instruction can be used several times in a program, but one instruction is
executed at a time.
Example
When X0 is turned ON, the data specified is sorted in ascending order. When
the sorting of the data specified is complete, M1029 is ON. When the
instruction is executed, the data specified can not be changed. If users want to
sort the data specified again, they can turn X0 from OFF to ON again.
X0
SORT
D0 K5 K5 D50 D100
1. The data which will be sorted is shown below.
m
2
columns of data
Column
1 2 3 4 5
Column
Row
Student
number
Chinese English Math Physics
1
(D0) 1 (D5) 90 (D10) 75 (D15) 66 (D20) 79
2
(D1) 2 (D6) 55 (D11) 65 (D16) 54 (D21) 63
3
(D2) 3 (D7) 80 (D12) 98 (D17) 89 (D22) 90
4
(D3) 4 (D8) 70 (D13) 60 (D18) 99 (D23) 50
m
1
rows of data
5
(D4) 5 (D9) 95 (D14) 79 (D19) 75 (D24) 69