Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Array Sort ArraySort Primary Secondary Sort Column
24 value1 25 value1 25 value2 25 value3Result is
24 value1 25 value2 25 value3 25 value1
It is possible to perform a complete secondary, tertiary, etc. sorts using 'ArraySort's range parameters. It just takes a few extra lines of script to implement.
Crude example. Bugs included at no extra charge.
; Create test data aTest = ArrDimension(4, 2) nDim1 = ArrInfo(aTest, 1) aTest[0,0] = 0 aTest[1,0] = 1 aTest[2,0] = 0 aTest[3,0] = 1 aTest[0,1] = 4 aTest[1,1] = 3 aTest[2,1] = 2 aTest[3,1] = 1 ; Primary Sort on first column. ArraySort(aTest, @ASCENDING, 0) ; Secondary sort on second column. nMax1 = nDim1 - 2 nStart = 0 For i = 0 To nMax1 If aTest[i, 0] == aTest[i + 1, 0] Then Continue If nStart < i Then ArraySort(aTest, @ASCENDING, 1, nStart, i) nStart = i + 1 Next If nStart < i Then ArraySort(aTest, @ASCENDING, 1, nStart, i) BreakPoint ; Check array contents in WB Studio. Exit
Article ID: W17667
Filename: Secondary Sort on Columns.txt
File Created: 2010:09:09:12:46:38
Last Updated: 2010:09:09:12:46:38