in My arraylist I am storing minutes format using some conversion of HH:MM:SS.
I want to sort the above arraylist contain minutes and picking of max and min minutes in the arraylist.
Please give me good suggestion
Thanks in advance
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
John WiesePosted Jun 2, 2010, 4:45 PM
I would suggest you consider creating your own ArrayList implementation that inherits from ArrayList. Then you could create your own Sort, Min & Max methods. Assuming you are simply storing the values as a string currently you would have some work to do in order to sort the arraylist or grab the min or max as there is no simple way.
LiyaPosted Jun 3, 2010, 3:05 AM
Or else you will have problem with sorting strings, since in this way "9" comes after "10"
madhuPosted Jun 3, 2010, 1:48 AM
I am getting the arraylist form database with datareader and storing in 'MyDiffTimeList' array list.
The 'MyDiffTimeList' items are 'hh:mm:ss' format
The above format converted to minutes like
Dim hh, mm, ss As String
hh = CType(Tcount.Substring(0, 2) * 3600, Integer).ToString
mm = CType(Tcount.Substring(3, 2) * 60, Integer).ToString
ss = CType(Tcount.Substring(6, 2), Integer).ToString
TimeCount = CType(hh, Integer) + CType(mm, Integer) + CType(ss, Integer)
Then I am doing in this way of max
Dim i As Integer
Dim max As Double
max = MyDiffTimeList(0)
For i = 0 To MyDiffTimeList.Count - 1
If max < MyDiffTimeList(i) Then
max = MyDiffTimeList(i)
End If
Next
is this way ok. or any suggestions in the above coding
Regards,
Madhu