D
Derek Martin
Hi there, I've asked before but never got an answer that could get me
completely to where I was heading. I have an arraylist that contains
defined objects and I would like to sort this arraylist based on the values
of one of the object's members.
Here is a bit of code to illustrate my setup:
Object construction and insertion:
Dim entity As New entityobjects(entitynamenodelist(i).InnerXml,
typenodelist(i).InnerXml, ...)
entityarraylist.add(entity)
----------------------------------------------------------------------------------------------
Object definition class:
Public Class entityobjects
Protected m_entityid As String
Protected m_entityname As String
Protected m_type As String
...
Public Sub New(ByVal entityname As String, ByVal type As String ...)
Me.entityname = entityname
Me.type = type
...
End Sub
----------------------------------------------------------------------------------------------
Now, I would like to list out the objects sorted by entityname:
'What can I put here to sort these???
for each entity as object in entityarraylist
richtextbox1.appendtext(entity.toString()) 'toString is overridden here
in the object class
next
----------------------------------------------------------------------------------------------
I have read that I can implement icomparable or icomparer in the object
class but can't quite put my finger on how?
Thank you!
Derek
completely to where I was heading. I have an arraylist that contains
defined objects and I would like to sort this arraylist based on the values
of one of the object's members.
Here is a bit of code to illustrate my setup:
Object construction and insertion:
Dim entity As New entityobjects(entitynamenodelist(i).InnerXml,
typenodelist(i).InnerXml, ...)
entityarraylist.add(entity)
----------------------------------------------------------------------------------------------
Object definition class:
Public Class entityobjects
Protected m_entityid As String
Protected m_entityname As String
Protected m_type As String
...
Public Sub New(ByVal entityname As String, ByVal type As String ...)
Me.entityname = entityname
Me.type = type
...
End Sub
----------------------------------------------------------------------------------------------
Now, I would like to list out the objects sorted by entityname:
'What can I put here to sort these???
for each entity as object in entityarraylist
richtextbox1.appendtext(entity.toString()) 'toString is overridden here
in the object class
next
----------------------------------------------------------------------------------------------
I have read that I can implement icomparable or icomparer in the object
class but can't quite put my finger on how?
Thank you!
Derek