IBM Support

Using LotusScript to sort values in a field

Technote (FAQ)


In Lotus Notes®, can you use LotusScript to sort an array of values in a field?


In releases 6.0 and later, the Lotus Domino® Directory template includes a QuickSort function in its Common Script library. You can either copy the related functions (the QuickSort function that is included uses two additional functions, DoQS and DoInsertSort) from the Domino Directory template (pubnames.ntf) or import them from the attached LSS file.
The QuickSort function is designed to perform optimally depending on the number of elements in the array and uses an Insertion Sort once the elements are close to being sorted. The Insertion Sort logic is also used if the number of elements is 10 or less.

NOTE: In the pubnames.ntf template, the QuickSort function is in the Common Script Library. You may have to rename it if you choose to copy it into a database or template that already contains a library named Common. For example, the mail templates have a Common library. It is important to rename the new library, not one that already exists.

How to add the functions using an LSS file


The LSS file above contains the QuickSort, DoQS, and DoInsertSort functions. Before importing the file, make sure that you do not have any similarly named functions.

1. Detach the quicksort.lss file above to a directory.

2. Open your LotusScript code and place the cursor in the Initialize event.

3. From the File menu, choose Import --> Find and select the quicksort.lss file from where you detached it --> click Import. NOTE: The import process will check to ensure that you are not overwriting existing functions (QuickSort, DoQS, DoInsertSort). If a conflict is detected, click Stop and rename any functions in your code that use these names.

How to call the QuickSort function

1. If you copied in the Common library, then add the following line to the (Options) code:

    Use "Common"
2. To call the function, simply call the QuickSort function, for example:

    Cross reference information
    Segment Product Component Platform Version Edition
    Messaging Applications IBM Notes Not Applicable Linux, Mac OS, Windows 8.0, 7.0, 6.5, 6.0 All Editions
    Messaging Applications IBM Domino Not Applicable AIX, i5/OS, Linux, Solaris, Windows, z/OS 8.0, 7.0, 6.5, 6.0 All Editions

    Historical Number


Document information

More support for: IBM Domino Designer

Software version: 6.0, 6.5, 7.0, 8.0

Operating system(s): Windows

Reference #: 1109011

Modified date: 22 February 2010

Translate this page: