You could also script a function reusable in similar cases (e.g. move a block of rows to top or bottom of a 1D/2D array), let's name the function _ArrayRowMove :
#Include <Array.au3>
#Include <MsgBoxConstants.au3>
; Local $aArray[] = ["A0", "B1", "C2", "D3", "E4", "F5", "G6", "H7"]
; or
Local $aArray[][] = [["A",0],["B",1],["C",2],["D",3],["E",4],["F",5],["G",6],["H",7]]
_ArrayDisplay($aArray, "before move")
_ArrayRowMove($aArray, 2, 5) ; rows 2 to 5 moved to top
; or
; _ArrayRowMove($aArray, 2, 5, False) ; rows 2 to 5 moved to bottom
If @error Then
Msgbox($MB_TOPMOST, "_ArrayRowMove", "error = " & @error)
Else
_ArrayDisplay($aArray, "after move")
EndIf
;==================================================================
Func _ArrayRowMove(ByRef $aArray, $iStart, $iEnd, $bTopDest = True)
If Not IsArray($aArray) Then Return SetError(1, 0, 0)
Local $aBackup, $iDims, $iRows, $iCols, $iInterval, $iInc = -1
$iDims = UBound($aArray, $UBOUND_DIMENSIONS)
$iRows = UBound($aArray, $UBOUND_ROWS)
$iCols = UBound($aArray, $UBOUND_COLUMNS) ; always 0 for 1D array (+++)
If $iDims < 1 Or $iDims > 2 Then Return SetError(2, 0, 0)
If $iRows = 0 Then Return SetError(3, 0, 0) ; not sure about this test
If $iStart = Default Or $iStart < 0 Then $iStart = 0
If $iEnd = Default Or $iEnd > $iRows - 1 Then $iEnd = $iRows - 1
$iInterval = $iEnd - $iStart
If $iInterval < 0 Then Return SetError(4, 0, 0)
$aBackup = $aArray
If $iDims = 1 Then ; 1D
If $bTopDest Then ; move to top
For $i = $iStart -1 To 0 Step -1
$iInc += 1 ; 0+
$aArray[$iEnd - $iInc] = $aBackup[$i]
Next
For $i = 0 To $iInterval
$aArray[$i] = $aBackup[$iStart + $i]
Next
Else ; move to bottom
For $i = $iEnd +1 To $iRows -1
$iInc += 1 ; 0+
$aArray[$iStart + $iInc] = $aBackup[$i]
Next
$iInc = -1
For $i = $iRows -1 - $iInterval To $iRows -1
$iInc += 1 ; 0+
$aArray[$i] = $aBackup[$iStart + $iInc]
Next
EndIf
Else ; 2D
If $bTopDest Then ; move to top
For $i = $iStart -1 To 0 Step -1
$iInc += 1 ; 0+
For $j = 0 To $iCols -1
$aArray[$iEnd - $iInc][$j] = $aBackup[$i][$j]
Next
Next
For $i = 0 To $iInterval
For $j = 0 To $iCols -1
$aArray[$i][$j] = $aBackup[$iStart + $i][$j]
Next
Next
Else ; move to bottom
For $i = $iEnd +1 To $iRows -1
$iInc += 1 ; 0+
For $j = 0 To $iCols -1
$aArray[$iStart + $iInc][$j] = $aBackup[$i][$j]
Next
Next
$iInc = -1
For $i = $iRows -1 - $iInterval To $iRows -1
$iInc += 1 ; 0+
For $j = 0 To $iCols -1
$aArray[$i][$j] = $aBackup[$iStart + $iInc][$j]
Next
Next
EndIf
EndIf
Return 1 ; success
EndFunc
Update Dec 23, 2022
* Added code for 1D array
* Added error checking