Micro Focus QTP (UFT) Forums
How to get data from data table in Ascending order - 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: How to get data from data table in Ascending order (/Thread-How-to-get-data-from-data-table-in-Ascending-order)



How to get data from data table in Ascending order - dipashri - 01-24-2014

hi friends,
Suppose there is a sheet in data table of qtp with values like 5,9,1,7 or g,a,r,q,b how to sort them and display in Ascending Order using script


RE: How to get data from data table in Ascending order - jacosta - 01-28-2014

Hi,

Try this code:

Code:
call SortArray()
Function SortArray()
'================================================
'Author:QTP Lab:a touch of madness!
'Date:23/11/2009
'Description:This function sorts an array into ascending
'            and descending order using .Net class methods.
'Function:SortArray()
'=========================================================
Dim myObj,MyArrAux
MyArrAux=""
Set myObj=CreateObject("System.Collections.ArrayList")
myObj.Add("Ba")
myObj.Add("R")
myObj.Add("A")
myObj.Add("Bb")
myObj.Add("S")
myObj.Add("M")
myObj.Add("D")
myObj.Add("J")
myObj.Add("Bc")
myObj.sort()

For each sNames in myObj
    MyArrAux=MyArrAux& sNames &":"
Next
msgbox MyArrAux,0,"Ascending order"

Set myObj=Nothing

End Function