2022.2

Table Of Contents
StringSort
StringSort is a convenience class that provides a generic sorting class for ActiveScript-compatible lan-
guages. It is a non-trivial task to sort data in scripting, especially in VBScript where there is no equi-
valent for the JScript sort function. It is designed as a list of strings. Each string in the list is a key based
on which the sort is done. Each key can have an optional integer value that can be used, for example,
to retrieve a record in an array.
To create a StringSort object, use CreateObject("MetadataLib.StringSort") or the {A07730B7-4100-
457E-91E2-31BFF24E1EC4} CLSID. Although the object is published by the metadata library, it is com-
pletely independent of the metadata and can be used in any script, including those run outside of Plan-
etPress Suite.
Methods
Name Returns Description
"Add(const String Key, Integer Value)" below Integer Adds a new item in the sort list.
Clear() Empties the sort list, removing all the strings.
"Count()" on the facing page Integer Returns the number of elements in the list.
"Delete(Integer Index)" on the facing page Removes an item from the sort list.
"Find(const String Key)" on the facing page Integer Finds an item in the list and returns its index.
"Key(Integer Index)" on the facing page String Returns the key at the specified index.
"Sort()" on the facing page Sorts the list.
"SortByValue()" on the facing page Sorts the list based on the value instead of the key.
"Value(Integer Index )" on page192 Integer Returns the value at the specified index.
Add(const String Key, Integer Value)
Adds a new string key in the list, with an optional associated integer Value.
Key
String on which the sort will be performed.
Value (optional)
Integer associated with the string. This value is not used and will not be changed by the sort class. If
the string goes to another position in the list after the sort, this value will move as well to the new
index of the string.
Return value: 0-based index (integer) of the newly added string. It is therefore always equal to Count-
1.
Page 190