|
CValueSet:Sort
The Sort method sorts the contents of the
CValueSet according to its values.
Syntax
CValueSet:Sort()
Remarks
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.
Example
The following example creates a CValueSet S and
then sorts its members by value:
|
S = new_valueset("number")
|
|
|
S:Add( "key_1", 158.25 )
|
|
|
S:Add( "key_2", -7.23 )
|
|
|
S:Add( "key_3", 78.6 )
|
|
|
S:List("Before sort:")
|
|
|
S:Sort()
|
|
|
S:List("After sort:")
|
|
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
Related Topics
CValueSet Class
Add
List
GetType
SortKey
Mira Pro x64 Script User's Guide, v.8.76 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.
|