请回答下列问题:
Dim a(1 To 100) As Integer
Dim n As Integer
Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim s As String, k As Integer
n = Val(Text1.Text)
For i = 1 To n
For j = 1 To n
k = (i - 1) * n + j
a(k) = Int(Rnd() * 45 + 5) * 2
s = s + " " + Str(a(k))
Next j
List1.AddItem s
Next i
End Sub
Private Sub Command2_Click()
Dim i As Integer, L As Integer, R As Integer
Dim f As Integer
For i = 1 To n
If i Mod 2 = 1 Then f = 1 Else f = -1
R = i * n
List2.AddItem sort(L, R, f)
Next i
End Sub
Function sort(left As Integer, right As Integer, order As Integer) As String
Dim i As Integer, j As Integer, k As Integer
Dim s As String, t As Integer
s = ""
For i = left To right - 1
k = i
For j = i + 1 To right
If Then k = j
Next j
If k <> i Then
t = a(k): a(k) = a(i): a(i) = t
End If
s = s + " " + Str(a(i))
Next i
sort = s
End Function