Function Sort Orders Class

SortCharactersIndirect

Performs an indirect sort of the characters within the string using a custom sort order. Takes a sort order like "FEDCBA" and a sort key like "ABCDEF" and sort data like "123456" and produces "654321". Result string will contain all of the characters from string vValue, NOT just the unique ones.

Signature (Visual Basic / VBA)

Public Function SortCharactersIndirect( _
      ByVal vSortKeys As Variant _
    , ByVal vSortData As Variant _
    , Optional ByVal vSortOrder As Variant _
    ) As Variant

Code Example

    SortCharactersIndirect("ABCDEF", "123456", "FEDCBA") = "654321"
    SortCharactersIndirect("214365", "UVWXYZ", "123456") = "VUXWZY"

Parameters

Parameter Description
vSortKeys String containing characters whose ASCII values represents pointers to the positions of the data within the string vSortData. Function returns Null if vSortKeys is Null or cannot be fixed up to a String.
vSortData String containing characters which represent the data to be sorted. Function returns Null if vSortData is Null or cannot be fixed up to a String.
vSortOrder String containing characters which describe the sort order/collating sequence. The position of each character in this string represents the sequence of the character with that ASCII value within the collating sequence. vSortOrder defaults the string produced by the EveryCharacter function if it is missing or Null or cannot be fixed up to a String. That string contains all the characters with ASCII values between 0 and 255, with those characters in sorted order based upon their ASCII value. This simulates the Binary sort order, making this function the same as (but slower than) SortCharactersBinary .

Notes & Version History

Algotithm This function currently uses a Shell Sort.