7 APPLICATION INSTRUCTION
7.17 Data operation instruction
559
7
Sorting 16-bit data
SORTTBL(_U)
These instructions sort data lines in the data table (sorting source) having ((m1)(m2)) points specified by (s) in the ascending
order based on the group data in the column number (n), and store the result in the data table (sorting result) having
((m1)(m2)) points specified by (d).
■Descriptions, ranges, and data types
■Applicable devices
• These instructions sort data lines in the data table (sorting source) having ((m1)(m2)) points specified by (s) in the
ascending order based on the group data in the column number (n), and store the result in the data table (sorting result)
having (m1m2) points specified by (d).
• The data table configuration is explained in an example in which the sorting source data table has 3 lines and 4 columns
(m1 = K3, m2 = K4). For the sorting result data table, understand (s) as (d).
• When the command input turns on, data sorting is started. Data sorting is completed after (m1) scans, and the instruction
execution complete flag SM8029 is set to on.
Ladder diagram Structured text
ENO:=SORTTBL(EN,s,m1,m2,n,d);
ENO:= SORTTBL_U(EN,s,m1,m2,n,d);
Operand Description Range Data type Data type (label)
(s) SORTTBL Head device number storing the data table 16-bit signed binary ANY16
SORTTBL_U 16-bit unsigned binary
(m1) Number of data (lines) 1 to 32 16-bit unsigned binary ANY16
(m2) Number of group data (columns) 1 to 6 16-bit unsigned binary ANY16
(d) SORTTBL Head device number for storing the operation result 16-bit signed binary ANY16
SORTTBL_U 16-bit unsigned binary
(n) Column number of group data (column) used as the basis of
sorting
16-bit unsigned binary ANY16
Operand Bit Word Double word Indirect
specification
Constant Others
X, Y, M, L,
SM, F, B, SB
U\G T, ST,
C, LC
T, ST, C, D,
W, SD, SW, R
U\G Z LC LZ K, H E $
(s)
(m1)
(m2)
(d)
(n)
Number of groups (m2 = K4)
Column No. 1 Column No. 2 Column No. 3 Column No. 4
Control number Height Weight Age
Number of data (m1) = 3 Line No. 1 (s) (s)+3 (s)+6 (s)+9
Line No. 2 (s)+1 (s)+4 (s)+7 (s)+10
Line No. 3 (s)+2 (s)+5 (s)+8 (s)+11