Sort Group Members Automatically

Copy the code into the group-mask of the NAB.
When saving a group-document, the member's list will automatically be sorted.
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document

array_sort = doc.Members

Call Quicksort( array_sort )
doc.Members = array_sort

End Sub



Sub Quicksort( array_sort )
Dim start%, ende%, starthelp%, endehelp%, start_ret%, ende_ret%,
maxlength%,stackpointer%, pivot%
Dim v_value, v_compare

' Abbruch falls nur 1 Element
If Ubound( array_sort ) < 1 Then Exit Sub
num& = True

For i% = 0 To Ubound(array_sort)
On Error Goto NOT_NUMERIC
tmp& = array_sort(i%)
Next

maxlength% = Ubound( array_sort )

' Stack initialisieren auf maximale Gr??e
Dim array_start() As Integer, array_ende() As Integer
Redim array_start( maxlength% ) As Integer
Redim array_ende( maxlength% ) As Integer

' Hilfsarray
Dim array_help() As Variant
Redim array_help( maxlength% ) As Variant

' Legt Anfangswerte auf Stack
array_start( 0 ) = Lbound( array_sort )
array_ende( 0 ) = Ubound( array_sort )

' Schleife -> solange Stack belegt ist
Do While stackpointer% >= 0

' Holte Arraybereich von Stack
start% = array_start( stackpointer% )
ende% = array_ende( stackpointer% )
stackpointer% = stackpointer% -1

' Eigentliche Sortierfunktion S T A R T
starthelp% = start%
endehelp% = ende%

' Pivotelement
pivot% = (start% + ende%) / 2
v_compare = array_sort( pivot% )

' Sortieren nach > Pivotelement und < Pivotelement
' Vor Pivotelement
Dim n%
For n% = start% To pivot% -1

v_value = array_sort( n% )

If num& Then
v_compare = Cint(v_compare)
v_value = Cint(v_value)
End If

If ( v_compare > v_value ) Then
array_help( starthelp%) = v_value
starthelp% = starthelp% + 1
Else
array_help( endehelp% ) = v_value
endehelp% = endehelp% -1
End If
Next

' Nach Pivotelement
For n% = ende% To pivot%+1 Step -1

v_value = array_sort( n% )

If num& Then
v_compare = Cint(v_compare)
v_value = Cint(v_value)
End If

If ( v_compare > v_value ) Then
array_help( starthelp%) = v_value
starthelp% = starthelp% + 1
Else
array_help( endehelp% ) = v_value
endehelp% = endehelp% -1
End If
Next

' Pivotelement wird zur?ck in Liste gelegt
array_help( starthelp% ) = v_compare

' Werte aus Hilfsarray werden zur?ckgeschrieben
For n% = start% To ende%
array_sort( n% ) = array_help( n% )
Next

' Sortierbereiche neu festlegen
start_ret% = endehelp% + 1
ende_ret% = ende%
start% = start%
ende% = starthelp% - 1

' Legt 1 Arraybereich auf Stack
If start% < ende% Then
stackpointer% = stackpointer% + 1
array_start( stackpointer% ) = start%
array_ende( stackpointer% ) = ende%

Dig Deeper on Domino Resources

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

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

SearchContentManagement

Close