PML Customisation
User Guide
Arrays
:
Arrays of Objects
: Using Block Evaluate to Sort an Array of Objects
Using Block Evaluate to Sort an Array of Objects
There are no built-in array methods yet for sorting an array of objects. A possible technique is to use a block evaluation to create an array of keys to sort:
- - Create a block to extract the object member on which to sort
!ExtractKeys = object BLOCK ('!MyEmployees[!Evalindex].Name')
- - Evaluate the block to generate an array of sort keys
!SortKeys = !MyEmployees.Evaluate(!ExtractKeys)
- - Create a new array containing the sorted element positions
!NewOrder = !SortKeys.SortedIndices()
- - Apply the sorted element positions to the original array
!MyEmployees.ReIndex(!NewOrder)
This Evaluate method is the equivalent of the older command:
VAR .. EVALUATE .. INDICES ARRAY
Note:
In particular that there is no automatic database navigation.
1974 to current year.
AVEVA Solutions Limited and its subsidiaries. All rights reserved.