rotsey Posted April 19, 2005 Posted April 19, 2005 Hi, I want to sort an ArrayList that contains structres. I have this code so far Public Structure statData Implements System.IComparable Public period As String Public player As String Public rnds As Long Public score As Single Public scoreRank As Long Public scOut As Single Public scOutRank As Long Public scIn As Single Public scInRank As Long Public net As Single Public netRank As Long Public points As Single Public pointsRank As Long Public putts As Single Public puttsRank As Long Public SortBy As String Public Function CompareTo(ByVal obj As Object) As Integer Implements IComparable.CompareTo Select Case SortBy Case "Score" Return Me.score.CompareTo(CType(obj, statData).score) Case "scOut" Return Me.score.CompareTo(CType(obj, statData).scOut) Case "scIn" Return Me.score.CompareTo(CType(obj, statData).scIn) Case "net" Return Me.score.CompareTo(CType(obj, statData).net) Case "Putts" Return Me.score.CompareTo(CType(obj, statData).putts) Case "Points" Return Me.score.CompareTo(CType(obj, statData).points) End Select End Function End Structure What I am not sure of is how to sort by setting the SortBy property. For example Dim st as statData Dim arr as ArrayList st.score = blah blah blah arr.Add(st) ... arr.Sort() How do I call the SortBy to in this code? Would appreciate any help Rotsey Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.