Document Review batch sorting

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

In order to use this setting, the Allow document sorting setting 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