<-- Previous || Up || Next -->

Sort Words Function
String Words Class

Public Function SortWords( _
      ByVal vValue As Variant _
    , Optional ByVal vSpecialSeparators As Variant _
    , Optional ByVal vCompare As Variant _
    , Optional ByVal vOutputSeparator As Variant _
    , Optional ByVal vSortWords As Variant _
    , Optional ByVal vUniqueWords As Variant _
    ) As Variant

Sort the words within a phrase,
create a string containing the unique words within a string,
or perform both operations at the same time (sort the unique words).

Examples:
    ? SortWords("This is a test.  This is also a test.", , , , True, False)
    a a also is is test test This This
    ? SortWords("This is a test.  This is also a test.", , , , True, True)
    a also is test This
    ? SortWords("This is a test.  This is also a test.", , , , False, True)
    This is a test also
    ? SortWords("This is a test.  This is also a test.", , , , False, False)
    This is a test This is also a test
See also:
    SummarizeText Function
    SpecialSeparators Property
    SortWordsSample Subroutine
    CombineOverlappingWords Function
vValue: String containing the words which are to be sorted, to have duplicates removed, or both. Function returns Null if vValue is Null or cannot be fixed up to a String.

vSpecialSeparators: String containing the "special" separators which describe how the characters of string vValue are formed into words. vSpecialSeparators defaults to the "special" separator string describing the ANSI Windows character set if it is missing or Null or cannot be fixed up to a String. The special separators string should contain one "special" character describing the classification of each character in the default character set. The character at position 1 (Mid$(vSpecialSeparators, 1, 1)) describes Chr$(0), the character at position 2 describes Chr$(1), etc.
The special separators string can contain the following four characters:

    " " (space)  Character will be ignored within the function like SummarizeText.
    "A"          Character is alphabetic.  Alphabetic characters are collected into words.
    "0" (zero)   Character is numeric.  Number characters are collected into numbers.
    "S"          Character is a symbol which will be considered to form its own word.
If the length of the special separators string is less than 256 characters, those characters whose classification was not provided will be considered "space" characters.

vCompare: Specifies the sort order/collating sequence used to sort words (when vSortWords is True) and specifies the type of comparison used to determine if words duplicate each other (when the vUniqueWords is True). vCompare defaults to (case-insensitive) Text comparisons if it is missing or Null or cannot be fixed up to a number, so that words like "This" will be considered duplicates of "this".

vOutputSeparator: String used to separate words within the output string. vOutputSeparator defaults to a space character if it is missing or Null or cannot be fixed up to a String.

vSortWords: Determines if the words within string vValue will be sorted. vSortWords defaults to True (meaning that words will be sorted) if it is missing or Null or cannot be fixed up to a number.

vUniqueWords: Determines if the words within string vValue will only appear once within the output. vUniqueWords defaults to False (meaning that duplicate words will be included in the result string once for each time they appear in the source string vValue) if it is missing or Null or cannot be fixed up to a number.

v1.1 BugFix: Made substantial improvements to the speed of this function when dealing with large strings (over 10K).

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.