Micro Focus QTP (UFT) Forums
Sort Order Help - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Sort Order Help (/Thread-Sort-Order-Help)



Sort Order Help - automation2012 - 03-01-2013

Code:
Set oDesc=Description.Create()
oDesc("micclass").value = "WebElement"
oDesc("class").Value = "order_details_main_boxes"
Set sLinks = Browser("Browser").Page("Page").ChildObjects(oDesc)
sLinkCount = sLinks.Count
PRINT sLinkCount
For i = 0 to sLinkCount - 1
iName= sLinks(i).GetROProperty("innertext")
iOrderNumber =Left(iName, 7)
PRINT "Order Number " &iOrderNumber
Next

Hi usng the above code i'm capturing order number details so when i run the script in my app i got the count value 2 ie.,

sLinkCount = 2
In the first loop i got Order Number = 5434565
In the second loop i got Order Number = 5434564

Now i want to check the sorting by taking these order numbers and wanted to store in array so that i want to check ascending/descending sorting...

Please help me out in this regard...


RE: Sort Order Help - vinod123 - 03-01-2013

Code:
arrCtry=Split(Browser("name:=QTP").Page("title:=QTP").WebList("name:=select1").GetROProperty("all items"),";")

Set objArray=DotNetFactory.CreateInstance("System.Collections.ArrayList","")

For i=0 to Ubound(arrCtry)
If arrCtry(i)<>"--Choose One--" Then
   objArray.Add(arrCtry(i))
End If
Next

objArray.Sort()

objArray.Insert 0,"--Choose One--"

For j=0 to Ubound(arrCtry)
strOuput=strOuput+objArray(j)
strOuput=strOuput+";"
Next

If strOuput=Browser("name:=QTP").Page("title:=QTP").WebList("name:=select1").GetROProperty("all items")+";" Then
Msgbox "The Weblist's values are sorted in alphabetical order"
Else
Msgbox "The Weblist's values are not sorted in alphabetical order"
End If



RE: Sort Order Help - automation2012 - 03-01-2013

Hi vinod, actualy i don't want to use split funjction...i need order number to be stored in an array for every for loop iteration so that i can use them to check sort order..please help in sorting order number values into an arrray...


RE: Sort Order Help - vinod123 - 03-01-2013

Code:
Dim i, j, tmp
Services.StartTransaction "BubbleSort"
For i = ( UBound( arr ) - 1 ) to 0 Step -1
For j = 0 to i
If arr( j ) > arr( j + 1 ) Then
tmp = arr( j + 1 )
arr( j + 1 ) = arr( j )
arr( j ) = tmp
End If
Next
Next
Services.EndTransaction "BubbleSort"

End Sub



RE: Sort Order Help - automation2012 - 03-06-2013

hi,

bubble sort method is not working for me...

order numbers i have stored in an array...
functionality is to check sort order when i click on order number column...so whenever i click on order number column it will change sort order from existing sort display....assume sort order is displaying in ascending order then if i click on order number column it will change to descending order...