VBA array sort function?

后端 未结 13 2223
北荒
北荒 2020-11-22 05:28

I\'m looking for a decent sort implementation for arrays in VBA. A Quicksort would be preferred. Or any other sort algorithm other than bubble or merge would suffice.

<
13条回答
  •  甜味超标
    2020-11-22 05:53

    I wonder what would you say about this array sorting code. It's quick for implementation and does the job ... haven't tested for large arrays yet. It works for one-dimensional arrays, for multidimensional additional values re-location matrix would need to be build (with one less dimension that the initial array).

           For AR1 = LBound(eArray, 1) To UBound(eArray, 1)
                eValue = eArray(AR1)
                For AR2 = LBound(eArray, 1) To UBound(eArray, 1)
                    If eArray(AR2) < eValue Then
                        eArray(AR1) = eArray(AR2)
                        eArray(AR2) = eValue
                        eValue = eArray(AR1)
                    End If
                Next AR2
            Next AR1
    

提交回复
热议问题