viernes, 19 de octubre de 2018
ordenar lista de tuplas
Versión 1
Dim elem As New List(Of String)
Dim a As Integer
Dim b As Integer
Dim temp As String
Dim c As Integer = -1
For i As Integer = 0 To elem.Count - 1
c += 1
For j As Integer = c To elem.Count - 1
a = elem(i).Split(",")(0)
b = elem(j).Split(",")(0)
If b < a Then
temp = elem(i)
elem(i) = elem(j)
elem(j) = temp
End If
Next
Next
elem.Clear()
Versión 2
Dim elem As New List(Of String)
Dim sep As Char = ","
Dim a As Integer
Dim b As Integer
Dim temp As String
Dim c As Integer = -1
For i As Integer = 0 To elem.Count - 1
c += 1
For j As Integer = c To elem.Count - 1
a = elem(i).Split(sep)(0)
b = elem(j).Split(sep)(0)
If b < a Then
temp = elem(i)
elem(i) = elem(j)
elem(j) = temp
ElseIf b = a Then
a = elem(i).Split(sep)(1)
b = elem(j).Split(sep)(1)
If b < a Then
temp = elem(i)
elem(i) = elem(j)
elem(j) = temp
End If
End If
Next
Next
elem.Clear()
Suscribirse a:
Comentarios de la entrada (Atom)
No hay comentarios.:
Publicar un comentario