Sorting by Object Number
It is often desireable to sort objects according to object number as this reflects the ordering of objects within a module.
if ("1.10" > "1.5")
{
print("We want to see this")
}
We can however pad out a legal number with leading zeroes using the lexNum() function so that it can be used lexicographically in comparisons or for sorting. Now running the following does produce the required output:
#include <lexnum.inc>
if (lexNum("1.10") > lexNum("1.5"))
{
print("We want to see this")
}
Sorting by Object Number (improved)
int legalCompare(string s1, string s2)
This function is a far more efficient way of comparing object numbers. Object numbers are legal paragraph numbers of the form 1.1, 1.2, 1.2.1 etc.
// Example usage
if (legalCompare("1.10","1.5") == 1)
{
print("We want to see this")
}
This function was originally developed as a callback function for sorting a column in a listView. For this reason, when bad parameters are passed it returns zero (no sorting applied). This can be changed by changing the return statement immediately after the lastError call.