#include <Array.au3>
Local $Array = _Twoarray()
_ArrayDisplay($Array, "排序前")
_Aftersorting($Array)
_ArrayDisplay($Array, "排序后")
;原数组
Func _Twoarray()
Local $Array[5][4] = [ _
[21, 20, 2, 5], _
[24, 25, 26, 27], _
[28, 29, 30, 31], _
[32, 33, 34, 35], _
[36, 37, 38, 39]]
Return $Array
EndFunc ;==>_Twoarray
;排序
Func _Aftersorting(ByRef $Array)
If Not IsArray($Array) Then Return SetError(1)
Local $aRet[0]
For $i = 0 To UBound($Array) - 1
For $j = 0 To UBound($Array, 2) - 1
ReDim $aRet[UBound($aRet) + 1]
$aRet[UBound($aRet) - 1] = $Array[$i][$j]
Next
Next
Local $i_ub = UBound($aRet)
For $i_count = 0 To $i_ub - 2
Local $i_se = $i_count
For $x_count = $i_count To $i_ub - 1
If Number($aRet[$i_se]) > Number($aRet[$x_count]) Then $i_se = $x_count
Next
Local $i_hld = $aRet[$i_count]
$aRet[$i_count] = $aRet[$i_se]
$aRet[$i_se] = $i_hld
Next
$i_count = 0
For $i = 0 To UBound($Array,2) - 1
For $j = 0 To UBound($Array) - 1
$Array[$j][$i] = $aRet[$i_count]
$i_count += 1
Next
Next
ReDim $aRet[0]
EndFunc ;==>_Aftersorting
|