’待排序数据存储在数组a中(a(1)~ a(n)),要求升序排列
For i = 1 To (n - 1) \ 2
For j = 1 To n - i * 2
If Then ‘⑴
t = a(j): a(j) = a(j + 2): a(j + 2) = t
End If
Next j
Next i
For i = 1 To n \ 2
j = 2 * i - 1
If a(j) > a(j+1) Then t = a(j): a(j) = a(j+1): a(j+1) = t
Next i
For i = Step 2 ‘⑵
t = a(i): j = i - 1
Do While t < a(j)
a(j + 1) = a(j): j = j - 1
Loop
a(j + 1) = t
Next i
⑴ ⑵