L = 1: R = n
Do While L < R
imin_1 = L: imin_2 = R
For i = L + 1 To R
If a(i) < a(imin_1) Then
imin_2 = imin_1
imin_1 = i
ElseIf a(i) < a(imin_2) Then
imin_2 = i
End If
Next i
If imin_1 <> L Then t = a(imin_1): a(imin_1) = a(L): a(L) = t
____________________
If imin_2 <> R Then t = a(imin_2): a(imin_2) = a(R): a(R) = t
L = L + 1: R = R - 1
Loop