3.1.5.2.2 CompareSortKey

This algorithm generates sort keys for two strings and uses the sort keys to provide a linguistically appropriate string comparison.

 COMMENT CompareSortKeys
 COMMENT  On Entry: SortKeyA - An array of bytes returned from
 COMMENT                       GetWindowsSortKey
 COMMENT            SortKeyB - An array of bytes returned from
 COMMENT                       GetWindowsSortKey
 COMMENT
 COMMENT  On Exit:  Result   - A value indicating if SortKeyA
 COMMENT                       is less than, equal to, or greater
 COMMENT                       than SortKeyB
  
 PROCEDURE CompareSortKeys
  
 SET index to 0
 WHILE index is less than Length(SortKeyA) and 
      index is also less than Length(SortKeyB)
  
      IF SortKeyA[index] is less than SortKeyB[index] THEN
           SET Result to "SortKeyA is less than SortKeyB"
           RETURN
      ENDIF
      IF SortKeyA[index] is greater than SortKeyB[index] THEN
           SET Result to "SortKeyA is greater than SortKeyB"
           RETURN
      ENDIF
  
 INCREMENT index
 ENDWHILE
  
 IF Length(SortKeyA) is equal to Length(SortKeyB) THEN
      SET Result to "SortKeyA is equal to SortKeyB"
 ELSE IF Length(SortKeyA) is less than Length(SortKeyB) THEN
      SET Result to "SortKeyA is less than SortKeyB"
 ELSE
      assert Length(SortKeyA) needs to be greater than Length(SortKeyB)
      SET Result to "SortKeyA is greater than SortKeyB"
 ENDIF
 RETURN

Any sorting mechanism can be used to arrange these strings by comparing their sort keys.