Manage Learn to apply best practices and optimize your operations.

# Fast Sort For Multi-Value Fields

I developed this script as an efficient way to sort multi-value fields. We
added a Sort button to the address book template group form so that group
administrators could simply add people to the end of the group and click the
sort button to re-order the list. The script can also be used in the exiting
event of a field to sort the entries. I've also used it to generate a single,
sorted keyword list from two sources.
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim k As Integer
Dim i As Integer
Dim j As Integer
Dim h As Integer
Dim r As Integer
Dim memberArray() As String
Dim temp As String

Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document

'Build an array of values to sort
For k = 0 To Ubound(doc.FieldNameToSort)
Redim Preserve memberArray(1 To k+1)
memberArray(k+1) = Cstr(doc.FieldNameToSort(k))
Next

'Set up for Shell sort algorithm
h = 1
Do While h < k
h = (h*3)+1
Loop
h = (h-1)/3
If h > 3 Then
h = (h-1)/3
End If

'Shell sort algorithm
Do While h > 0
For i = 1+h To k
temp = memberArray(i)
j = i-h
Do While j >0
If memberArray(j)>temp Then
memberArray(j+h) = memberArray(j)
memberArray(j) = temp
Else
Exit Do
End If
j = j-h
Loop
Next i
h = (h-1)/3
Loop

'Write new field value to back-end doc and reload front-end doc
Call doc.ReplaceItemValue("FieldNameToSort", memberArray)

End Sub

#### Start the conversation

Send me notifications when other members comment.

## SearchWindowsServer

• ### Windows Server certifications retirement plan a blow to admins

This latest decision by Microsoft to drop the MCSA, MCSD and MCSE certifications is another step to push customers toward the ...

• ### Do you need to make Exchange Online backups?

Microsoft has several protective measures in place to let customers restore deleted mail in Office 365, but backup vendors will ...

• ### Updated Exchange Online PowerShell module adds reliability, speed

Microsoft assists Exchange Online administrators who rely on PowerShell by reworking the underlying functionality of several ...

## Search400

• ### iSeries tutorials

Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

• ### V6R1 upgrade planning checklist

When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

• ### Connecting multiple iSeries systems through DDM

Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

## SearchDataCenter

• ### Build a migration plan for enterprise edge infrastructure

Micro data centers are essential to edge computing use cases. Build an effective migration plan through site selection, ...

• ### Tech giants aim supercomputers, clouds at finding a COVID-19 cure

The new COVID-19 HPC consortium comprised of tech giants, national labs and academia are using supercomputers and clouds to speed...

• ### Top vendor SDDC certification programs for admins

If you decide to grow your knowledge of software-defined data center technologies, VMware, Nuage Networks and Microsoft offer ...

## SearchContentManagement

• ### Creating digital experiences key to driving exceptional CX

The way in which businesses build digital experiences is ever-evolving. It's a race to create easier-to-use customer interfaces ...

• ### Vendors offer free remote work technology for telecommuting

It's more than a marketing ploy: Cloud technology vendors, seeing their own issues enabling remote work, extend paid products to ...

• ### How businesses should deal with enterprise search issues

Enterprise search issues frequently complicate user experience with ECM systems. While users may face many problems, they also ...

Close