//先按照LocationNo排序,再按照DNNoDNItemNo排序
Private Sub Sort(ByVal boxList As IList(Of ShippingServiceDTO.SuggestionBox))
Dim locationNo As String = ""
Dim boxNo As String = ""
Dim fIDNo As String = ""
Dim mLFB As String = ""
Dim quantity As String = ""
Dim status As String = ""
Dim dNNoDNItemNo As String = ""
Dim rExChange As Integer
For i As Integer = 0 To boxList.Count - 1
For j As Integer = i + 1 To boxList.Count - 1
rExChange = SortContext(boxList(i).LocationNo, boxList(j).LocationNo)
If (rExChange = 0) Then
rExChange = SortContext(boxList(i).DNNoDNItemNo, boxList(j).DNNoDNItemNo)
End If
If (rExChange = 1) Then
locationNo = boxList(j).LocationNo
boxNo = boxList(j).BoxNo
fIDNo = boxList(j).FIDNo
mLFB = boxList(j).MLFB
quantity = boxList(j).Quantity
status = boxList(j).Status
dNNoDNItemNo = boxList(j).DNNoDNItemNo
boxList(j).LocationNo = boxList(i).LocationNo
boxList(j).BoxNo = boxList(i).BoxNo
boxList(j).FIDNo = boxList(i).FIDNo
boxList(j).MLFB = boxList(i).MLFB
boxList(j).Quantity = boxList(i).Quantity
boxList(j).Status = boxList(i).Status
boxList(j).DNNoDNItemNo = boxList(i).DNNoDNItemNo
boxList(i).LocationNo = locationNo
boxList(i).BoxNo = boxNo
boxList(i).FIDNo = fIDNo
boxList(i).MLFB = mLFB
boxList(i).Quantity = quantity
boxList(i).Status = status
boxList(i).DNNoDNItemNo = dNNoDNItemNo
End If
Next
Next
End Sub
Private Function SortContext(ByVal strI As String, ByVal strJ As String) As String
Dim iCount As Integer
Dim arri() As Char
Dim arrj() As Char
Dim rExChange As Integer
arri = strI.ToCharArray()
arrj = strJ.ToCharArray()
If (arri.Length < arrj.Length) Then
iCount = arri.Length
Else
iCount = arrj.Length
End If
For m As Integer = 0 To iCount - 1
If (arri(m) > arrj(m)) Then
rExChange = 1
Exit For
End If
If (arri(m) < arrj(m)) Then
rExChange = -1
Exit For
End If
If (arri(m) = arrj(m)) Then
rExChange = 0
End If
Next
If (rExChange = 0) Then
If (arri.Length > arrj.Length) Then
rExChange = 1
End If
If (arri.Length < arrj.Length) Then
rExChange = -1
End If
End If
Return rExChange
End Function
VB冒泡排序
最新推荐文章于 2022-03-06 14:17:47 发布