CValueSet:Sort
The Sort method sorts the contents of the CValueSet according to its values.
CValueSet:Sort()
When the set has type "string", the sorting results may be confusing because string sorting uses standard rules based on the decimal values of the ASCII character set. For example, "my value F" sorts to a lower set index than "my value c". This happens because the "F" character has ASCII decimal value 70 whereas "c" has ASCII decimal value 99. For details, see the ASCII character set on the Web.
The following example creates a CValueSet S and then sorts its members by value:
|
-- constructor, set to values of type "number" |
|
-- add a key and value at index 1 |
|
-- add a key and value at index 2 |
|
-- add a key and value at index 3 |
|
|
|
-- sort set members by value |
|
|
Below is the result of the previous script as listed in a CTextView window:
Before Sort:
key_1 158.25
key_2 -7.23
key_3 78.6
After Sort:
key_2 -7.23
key_3 78.6
key_1 158.2
CValueSet Class, Add, List, GetType, SortKey
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.