Document Review batch sorting

The following diagram shows the sequence of events initiated by the user request to sort a batch. In the BeforeSortDocuments event, the sequence how documents are sorted can be influenced, without scripting they are sorted alphabetically by their class name. This event is only available for the Document Review module, additionally you can check the property Project.ScriptExecutionMode.

In order to use this option, the "Allow document sorting" option must be selected in the Extended Synchronization Settings window when you configure a batch class.


Sort Documents sequence image

The following example sorts a batch in reverse order.

Private Sub Batch_BeforeSortDocuments(ByRef pDocumentSortList() As String)

    Dim classCount As Integer
    classCount = Project.ClassCount
    Dim classList() As String
    ReDim classList(classCount - 1)

    Dim i As Integer
    For i = 0 To Project.ClassCount - 1
        classList(i) = Project.ClassByIndex(i).Name
    Next

    Dim bUnsorted As Boolean
    bUnsorted = True

    Do While bUnsorted
      bUnsorted = False

      For i = 0 To classCount - 2
         If StrComp(classList(i), classList(i + 1)) <> 1 Then
            Dim helperString As String
            helperString = classList(i)
            classList(i) = classList(i + 1)
            classList(i + 1) = helperString
            bUnsorted = True
         End If
      Next
    Loop
    
				pDocumentSortList = classList

End Sub