Automating QTP Test Automation Home Automation Articles Downloads QTP Gotchas Links Books Contact About Site Map
General Function - Sort ArrayThis function sorts an array using the .NET System.Collections.ArrayList Download it Here (right-click and then save target as). (NOTE - you can just cut & paste from below, but the formatting will have multiple spaces instead of tabs).
'=========================================================================
Sub Gen_SortArray(aInput) 'This function sorts an array using the .NET System.Collections.ArrayList 'Usage: 'Call Gen_SortArray(aRows) 'Where aRows is a simple one-dimensional array containing data Dim oList, sItem, iIndex Set oList = CreateObject("System.Collections.ArrayList") 'Load the object For iIndex = lBound(aInput) to uBound(aInput) oList.Add aInput(iIndex) Next 'Sort it oList.Sort() 'Get the data back iIndex = lBound(aInput) For Each sItem In oList aInput(iIndex) = sItem iIndex = iIndex + 1 Next Set oList = Nothing End Sub '========================================================================= |