R RAJAN MBA Member Licensed User Longtime User Apr 20, 2014 #1 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)
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)
Erel B4X founder Staff member Licensed User Longtime User Apr 21, 2014 #2 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
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)