Function Sort Orders Class

IsStringSorted

Return True if the characters in a string are in ascending sorted order when examined from left to right.

Signature (Visual Basic / VBA)

Public Function IsStringSorted( _
      ByVal vString As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Variant

Code Example

    IsStringSorted("AaBbCc", vbTextCompare) = True
    IsStringSorted("AaBbCc", vbBinaryCompare) = False
    IsStringSorted("ABCabc", vbBinaryCompare) = True
    IsStringSorted("ABCabc", vbTextCompare) = False
    IsStringSorted("ABCabc") = IsStringSortedBinary("ABCabc")

Parameters

Parameter Description
vString String whose characters are examined from left-to-right to determine if they are in ascending order. Function returns Null if vString is Null or cannot be fixed up to a String. Empty strings and one character long strings are considered sorted.
vCompare specifies the type of string comparison used to determine if characters match. vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number, which is the same as calling the IsStringSortedBinary function.