\' Ensure that the user has picked a valid DimensionToSort If DimensionToSort = 1 then OtherDimension = 0 ElseIf DimensionToSort = 0 then OtherDimension = 1 Else \'Shoot, invalid value of DimensionToSort Response.Write \"Invalid dimension for DimensionToSort: \" & _ \"must be value of 1 or 0.\" Response.End End If
For row = 0 To UBound( arrArray, column ) - 1 \'Start outer loop.
\'Take a snapshot of the first element \'in the array because if there is a \'smaller value elsewhere in the array \'we\'ll need to do a swap. StartingKeyValue = arrArray ( row, DimensionToSort ) StartingOtherValue = arrArray ( row, OtherDimension )
\' Default the Starting values to the First Record NewStartingKey = arrArray ( row, DimensionToSort ) NewStartingOther = arrArray ( row, OtherDimension )
swap_pos = row
For j = row + 1 to UBound( arrArray, column ) \'Start inner loop. If arrArray ( j, DimensionToSort ) < NewStartingKey Then \'This is now the lowest number - \'remember it\'s position. swap_pos = j NewStartingKey = arrArray ( j, DimensionToSort ) NewStartingOther = arrArray ( j, OtherDimension ) End If Next
If swap_pos <> row Then \'If we get here then we are about to do a swap \'within the array. arrArray ( swap_pos, DimensionToSort ) = StartingKeyValue arrArray ( swap_pos, OtherDimension ) = StartingOtherValue
\' Ensure that the user has picked a valid DimensionToSort If DimensionToSort = 2 then OtherDimensionA = 0 OtherDimensionB = 1 ElseIf DimensionToSort = 1 then OtherDimensionA = 0 OtherDimensionB = 2 ElseIf DimensionToSort = 0 then OtherDimensionA = 1 OtherDimensionB = 2 Else \'Shoot, invalid value of DimensionToSort Response.Write \"Invalid dimension for DimensionToSort: \" & _ \"must be value of 2, 1 or 0.\" Response.End End If
For row = 0 To UBound( arrArray, column ) - 1 \'Start outer loop. \'Take a snapshot of the first element \'in the array because if there is a \'smaller value elsewhere in the array \'we\'ll need to do a swap. StartingKeyValue = arrArray ( row, DimensionToSort ) StartingOtherValueA = arrArray ( row, OtherDimensionA ) StartingOtherValueB = arrArray ( row, OtherDimensionB )
\' Default the Starting values to the First Record NewStartingKey = arrArray ( row, DimensionToSort ) NewStartingOtherA = arrArray ( row, OtherDimensionA ) NewStartingOtherB = arrArray ( row, OtherDimensionB )
swap_pos = row
For j = row + 1 to UBound( arrArray, column ) \'Start inner loop. If arrArray ( j, DimensionToSort ) < NewStartingKey Then \'This is now the lowest number - \'remember it\'s position. swap_pos = j NewStartingKey = arrArray ( j, DimensionToSort ) NewStartingOtherA = arrArray ( j, OtherDimensionA ) NewStartingOtherB = arrArray ( j, OtherDimensionB ) End If Next
If swap_pos <> row Then \'If we get here then we are about to do a swap \'within the array. arrArray ( swap_pos, DimensionToSort ) = StartingKeyValue arrArray ( swap_pos, OtherDimensionA ) = StartingOtherValueA arrArray ( swap_pos, OtherDimensionB ) = StartingOtherValueB
Eagleeye - du har reddet mig igen! ;-) Tak for hjælpen...
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.