Have you ever needed to sort your dictionary to have the values appear
in order?  Take a look at the DotnetFactory version of the
SortedList.  Create the list in any key order you want and the results
are printed out sorted.  This works for keys being either numerical or
strings.

One surprising result when using strings as keys was that uppercase
was displayed immediately below the lowercase.  Examine the "o" and
"O", change locations of the entries.

I do not know if the sort order can be changed to ascending or
descending.

' a sorted list is a dictionary where the keys are sorted on a print
out
'sl = sortedList
Set mysl =
DotnetFactory.CreateInstance("System.Collections.SortedList")

mysl.add 1.3, "fox"
mysl.add 1.4, "jumped"
mysl.add 1.5, "over"
mysl.add 1.2, "brown"
mysl.add 1.1, "quick"
mysl.add 1.0, "The"
mysl.add 1.6, "the"
mysl.add 1.8, "dog"
mysl.add 1.7, "lazy"

Set myEnumerator =
DotnetFactory.CreateInstance("System.Collections.IDictionaryEnumerator")
Set myEnumerator = mysl.getEnumerator

While myEnumerator.movenext
        print "Key = " & myEnumerator.Key & ": value = " & myEnumerator.value
Wend
print vblf
Set mysl_2 =
DotnetFactory.CreateInstance("System.Collections.SortedList")

mysl_2.add "b", "baby"
mysl_2.add "z", "zero"
mysl_2.add "a", "apple"
mysl_2.add "c", "carrot"
mysl_2.add "o", "orange"
mysl_2.add "p", "pear"
mysl_2.add "a.1", "annoy"
mysl_2.add "O", "juice"

Set myEnumerator_2 =
DotnetFactory.CreateInstance("System.Collections.IDictionaryEnumerator")
Set myEnumerator_2 = mysl_2.getEnumerator

While myEnumerator_2.movenext
        print "Key = " & myEnumerator_2.Key & ": value = " &
myEnumerator_2.value
Wend

Enjoy,

Parke

-- 
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

Reply via email to