' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.Collections

Namespace E
    Public Class MyData
        Private _v As Integer
        Private _s As String
        Public Sub New()
            MyClass.New(0, "")
        End Sub
        Public Sub New(ByVal v As Integer, ByVal s As String)
            _v = v
            _s = s
        End Sub
        Public Property V() As Integer
            Get
                Return _v
            End Get
            Set
                _v = value
            End Set
        End Property
        Public Property S() As String
            Get
                Return _s
            End Get
            Set
                _s = value
            End Set
        End Property
        Public Overloads Overrides Function ToString() As String
            Return ("(" & _v & "," & _s & ")")
        End Function
    End Class 
    Public Class MyDataCollection
    Inherits CollectionBase
        Default Public ReadOnly Property Blubber(ByVal index As Integer) As MyData
            Get
                Return CType(List(index), MyData)
            End Get
        End Property
        Public Function Add(ByVal value As MyData) As Integer
            Return List.Add(value)
        End Function
        Public Sub Sort(ByVal cmp As IComparer)
            Me.InnerList.Sort(cmp)
        End Sub
    End Class 
    Public Class MyDataComparerV
    Implements IComparer
        Function Compare(ByVal o1 As Object, ByVal o2 As Object) As Integer Implements IComparer.Compare
            Return (CType(o1, MyData).V - CType(o2, MyData).V)
        End Function
    End Class 
    Public Class MyDataComparerS
    Implements IComparer
        Function Compare(ByVal o1 As Object, ByVal o2 As Object) As Integer Implements IComparer.Compare
            Return CType(o1, MyData).S.CompareTo(CType(o2, MyData).S)
        End Function
    End Class 
    Public Class MainClass
        Public Shared Sub Main(ByVal args As String())
            Dim mdc As MyDataCollection = New MyDataCollection
            mdc.Add(New MyData(2, "A"))
            mdc.Add(New MyData(1, "CCC"))
            mdc.Add(New MyData(3, "BB"))
            Dim i As Integer
            For i = 0 To mdc.Count-1
                Console.WriteLine(mdc(i))
            Next
            mdc.Sort(New MyDataComparerV)
            For i = 0 To mdc.Count-1
                Console.WriteLine(mdc(i))
            Next
            mdc.Sort(New MyDataComparerS)
            For i = 0 To mdc.Count-1
                Console.WriteLine(mdc(i))
            Next
        End Sub
    End Class 
End Namespace
