Android Question Sort contacts on TimesContacted

RAJAN MBA

Member
Licensed User
Longtime User
How to sort contacts based on the number of times contacted? I Know both codes tried are wrong:
Code: Copy
'listofContacts is a list
listofContacts = Contacts2.GetAll(True,False)
listofContacts.Sort(Contact.TimesContacted)
and
Code: Copy
'listofContacts is a list
listofContacts = Contacts2.GetAll(True,False)
listofContacts.SortType("TimesContacted",True)
 
You will need to create a type that holds the contact object and the count:
Code: Copy
Type ContactAndTimes (Cont As Contact, Times As Int)

Code: Copy
Dim list1 As List
list1.Initialize
For Each c As Contact In listOfContacts
 Dim t As ContactAndTimes
 t.Initialize
 t.Cont = c
 t.Times = c.TimesContacted
 list1.Add(t)
Next

'now you can sort the new list
list1.SortType("Times", True)
 
Upvote 0
Back
Top