Insertion Sort - index is not taking a value

40 views Asked by At

I am trying to learn how to write an insertion sort, but i have a problem. Index wont take the value of counter.

For counter = 1 To length - 1

            temp = arraySort(counter)
            index = counter

            While index > 0 And temp < arraySort(index - 1)

                arraySort(index) = arraySort(index - 1)
                index = index - 1

            End While

            arraySort(index) = temp

        Next

I would expect that index would take a value, and it does if I put a breakpoint on the line index = counter, but otherwise no value is taken.

0

There are 0 answers