//基于ST语言的PLC冒泡排序法
VAR_IN_OUT
Data : ARRAY[*] OF INT;
END_VAR
VAR
i : INT;
Temp_Data : INT;
END_VAR
//冒泡排序
FOR i := DINT_TO_INT(LOWER_BOUND(Data,1)) TO DINT_TO_INT(UPPER_BOUND(Data,1) - LOWER_BOUND(Data,1)) + 1 DO
IF Data[i] > Data[i + 1] THEN
Temp_Data := Data[i];
Data[i] := Data[i + 1];
Data[i + 1] := Temp_Data;
END_IF
END_FOR