Quote Originally Posted by RobertLees
Hi

I have a dynamic array. Each row contains 7 numeric values. I want to sort this array by field7 within field6 within field5, etc up to field1.

My first thought is to redim the array to give an empty row at the end, and use it to shiffle out of sequence rows. Or I could just dump the out-of-sequence row data into other fields.

What do you think ?

Regards
Robert
I'm an old time COBOL programmer and we sometimes used a bubble sort. I Googled it and found a Visual Basic version. Here is the link which contains some forms to test the results.

http://zone.ni.com/devzone/conceptd....256E5C000030C6

Here is the code.

VB Code:
  1. Public Sub BubbleSort(ByRef sortArray() As Integer)
  2. Dim i As Integer
  3. Dim j As Integer
  4. Dim Temp As Integer
  5. For i = LBound(sortArray) To UBound(sortArray)
  6. For j = LBound(sortArray) To (UBound(sortArray) - i - 1)
  7. If sortArray(j + 1) < sortArray(j) Then
  8. Temp = sortArray(j) 'swap if the two items
  9. sortArray(j) = sortArray(j + 1) 'are out of order
  10. sortArray(j + 1) = Temp
  11. End If
  12. Next j
  13. Next i
  14. End Sub

If this doesn't fit the bill Google on "bubble sort" some more.