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

Inverse Permutation Function
Character Arrays Class

Public Function InversePermutation( _
    ByVal vString As Variant _
    ) As Variant

Create the inverse permutation of the characters within a string.

    InversePermutation("24315") = "41325"
    InversePermutation("68759") = "85769"
See also:
    TranspositionOfOrder Function
Summary: Function assumes that the string vString represent a permutation where the ASCII value of each character represents the number of the item (relative to the minimum ASCII value of the string plus one) and the character position represents sequence of the item within the permutation. In the inverse permutation, the ASCII value of each character represents the sequence of the item and the position of the character represents number of the item. For example, the vString value "24315" represents a permutation of five items with those items in the following order: item #2, item #4, item #3, item #1, item #5. The inverse permutation of that string is "41325" which represents that the sequence within the permutation of item #1 is 4, item #2 is 1, item #3 is 3, item #4 is 2, and item #5 is 5.
Note: Function assumes that the characters in string vString form a contiguous range of ASCII values when sorted by their ASCII value. For example, "24315" would be a valid string but "25467" would not because the character "3" is missing.
Note: Function uses the ASCII value of characters to determine if they match, which is in effect the same as using Binary comparisons.

vString: String containing the characters which each represent the number of a distinct item in a permutation. Function returns Null if vString is Null or cannot be fixed up to a String.

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