|
只会最简单的Bubble Sort,看一下是否是需要的效果。
- Sub zz()
- Dim t
- Dim arr, i&, j&, x&, y&, k
- Dim vSwap
- t = Timer
- 'arr = [a1].CurrentRegion.Value
- arr = [a3].CurrentRegion.Value
- x = UBound(arr, 2): y = UBound(arr)
- ReDim brr(1 To y, 1 To x)
- For i = 1 To y
- For j = 1 To x
- brr(i, j) = Val(arr(i, j))
- Next
- Next
- 'For i = 1 To y
- ' k = Application.Index(arr, i, 0)
- ' For j = 1 To x
- ' brr(i, j) = Application.Small(k, j)
- ' Next
- 'Next
- For i = 1 To y
- For j = 1 To x
- For k = j + 1 To x
- If brr(i, j) > brr(i, k) Then vSwap = brr(i, j): brr(i, j) = brr(i, k): brr(i, k) = vSwap
- Next k
- Next j
- Next i
- [g3].Resize(y, x) = brr
- Debug.Print Timer - t
- End Sub
复制代码 |
|