183
4
4 Instructions 4.5.3 Table Operation
SORT2: Data sorting 2
◆
Overview
The SORT2 instruction sorts the data of the designated column in ascending or descending order by row.
Data is stored consecutively by row for easy addition of row data.
SORT2 S m1 m2 D n
Data sorting 2 Applicable model:
H3U
S
Source
address
Start number of elements that store a data table
(which occupies m1 x m2 points)
16-bit instruction
(11 steps)
SORT2:
Continuous
execution
32-bit instruction (21
steps)
DSORT2: Continuous
execution
m1 Row count Number of rows; value range: 1 to 32
m2
Column
count
Number of columns; value range: 1 to 6
D
Destination
address
Start number of elements that store the operation
result (which occupies m1 x m2 points)
n
Target
column
Number of the column whose data is sorted; value
range: 1 to m2
◆
Operands
Operand
Bit Element Word Element
System·User System·User Bit Designation Indexed Address Constant
Real
Number
S X Y M T C S SM D R T C SD KnX KnY KnM KnS KnSM
V,Z
Modication K H E
m1 X Y M T C S SM D R T C SD KnX KnY KnM KnS KnSM
V,Z
Modication K H E
m2 X Y M T C S SM D R T C SD KnX KnY KnM KnS KnSM
V,Z
Modication K H E
D X Y M T C S SM D R T C SD KnX KnY KnM KnS KnSM
V,Z
Modication K H E
n X Y M T C S SM D R T C SD KnX KnY KnM KnS KnSM
V,Z
Modication K H E
Note: The elements in gray background are supported.
◆
Function
The data of the nth column of a data table from head address [S] which occupies m1 x m2 points is sorted
in ascending or descending order by row. The result is stored in a data table from head address [D] which
occupies m1 x m2 points.
The ON/OFF state of M8165 determines the sorting order. When M8165 = ON, sorting is in descending
order; when M8165 = OFF, sorting is in ascending order.
Data sorting starts when the instruction ow is active. Sorting is completed after the number of scans
reaches m1. Then the execution complete ag M8029 is set to ON.
The following shows the sorting process of a data table which occupies 3 x 3 points.