Sort an Arraylist holding an array of a custom class object of Orders

I need to sort an arraylist which holds a array of objects called orders.
Orders has a property called OrderDate and a List Of testCodes.
I want to sort the Araylist in asc OrderDate
here is some code snippet on how the arraylist gets populated

Dim deliveryOrders as New Arraylist
Dim orders as Orders
Dim orders.TestCodes - new List(of testcodes)
order .OrderDate = '3/1/2001'
blah blah blah

deliveryOrders.Add(orders)
 Need to sort this deliveryOrders arraylist
Public Class Order    
    Private _OrderDate As String   
    Private _Tests As List(Of TestCodes)
	
	Public Property CollectionDate() As String
        Get
            Return _CollectionDate
        End Get
        Set(ByVal value As String)
            _CollectionDate = value
        End Set
    End Property
	
    Public Property Tests() As List(Of TestCodes)
        Get
            Return _Tests
        End Get
        Set(ByVal value As List(Of TestCodes))
            _Tests = value
        End Set
    End Property
End Class

Public Class TestCodes
    Private _TestCode As String
    Private _Description As String
   
    Public Property TestCode() As String
        Get
            Return _TestCode
        End Get
        Set(ByVal value As String)
            _TestCode = value
        End Set
    End Property
    Public Property Description() As String
        Get
            Return _Description
        End Get
        Set(ByVal value As String)
            _Description = value
        End Set
    End Property


End Class

Open in new window

LVL 1
countrymeisterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
You have a sort method

deliveryOrders.Sort()
0
Jorge PaulinoIT Pro/DeveloperCommented:
But you can use SortedList or a SortedDictionary. They are strong typed classes and it will do what you want.

Dim deliveryOrders As New SortedList(Of Integer, Order)
Dim deliveryOrders As New SortedDictionary(Of Integer, Order)
0
countrymeisterAuthor Commented:
I am not clear  on how would it sort on the Orders OrderDate field, there is another field called testodes. What if I add few new fields to the Orders class.

I want to specifically sort on the OrderDate field
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Jorge PaulinoIT Pro/DeveloperCommented:
Have you tried?
0
countrymeisterAuthor Commented:
Yes I did try deliveryOrders.Sort()
 it gave me the following error, at Least  one object must Implement Icomparable
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
countrymeisterAuthor Commented:
Pleaase refund the points as I resolved this issue myself
What was needed was the implementation of the Icomparable and Icomaprer interfaces
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.