Re: Help with sorting an Arraylist that contains Structures
- From: "Justin" <None@xxxxxxxx>
- Date: Thu, 21 Aug 2008 22:38:29 -0700
Cool, I'll check it out. Thanks.
"Jack Jackson" <jjackson@xxxxxxxxxxxxxxxx> wrote in message news:c0jsa4hrrfchq8o584o27cule3p5d6gp6s@xxxxxxxxxx
The generic List(Of T) is in 2.0. Its advantage over ArrayList is.
that the contents of the list is typed so you don't have to cast the
contents and therefore avoid runtime errors if you make a mistake
casting the contents. I also strongly urge you to use it instead of
ArrayList.
On Thu, 21 Aug 2008 20:48:26 -0700, "Justin" <None@xxxxxxxx> wrote:
First, until just now I never heard of "lists". However you mention VS2008
specifically and while I am using VS2008 I'm wanting to stay with in the
confines of framework 2. Does your suggestion do that? If so then I'll
read up on it.
Googling "VB.NET list" came up with nothing but arraylists and listboxes.
I already know arraylists and I already know how to check for dups before
adding so it was pretty simple to bang out the code. This arraylist is used
all over my app.
"Bill McCarthy" <Bill@xxxxxxxxxxxxx> wrote in message
news:127A8FEC-F7C3-4C20-A160-323A34539761@xxxxxxxxxxxxxxxx
Hi Justin,
First, why are you using ArrayList ? You should use the generic List, eg.
Dim myList as New List(Of TabStructure)
Then, assuming you are using VB 2008, you can pass in a lambda function to
the sort method:
myList.Sort(Function(x, y) x.TabName.CompareTo(y.TabName))
"Justin" <None@xxxxxxxx> wrote in message
news:OEUepa%23AJHA.1828@xxxxxxxxxxxxxxxxxxxxxxx
Ok, I give up. I can't seem to construct a decent (productive) way of
sorting my arraylist.
I have a structure of two elements:
Structure TabStructure
Dim TabName As String
Dim FullFilePath As String
End Structure
Then for example I:
Dim tab as New TabStructure
some code
Then I add "tab" to an arraylist.
At some point I loop through my arraylist, grab data and create tabs from
it. Of course the resulting list of tabs are out of sequence.
Can someone help me to sort my array list alphabetically by
TabStructure.TabName?
I would greatly appreciate it.
- References:
- Help with sorting an Arraylist that contains Structures
- From: Justin
- Re: Help with sorting an Arraylist that contains Structures
- From: Bill McCarthy
- Re: Help with sorting an Arraylist that contains Structures
- From: Jack Jackson
- Help with sorting an Arraylist that contains Structures
- Prev by Date: Re: Help with sorting an Arraylist that contains Structures
- Next by Date: map 2 Dirves
- Previous by thread: Re: Help with sorting an Arraylist that contains Structures
- Next by thread: Re: Help with sorting an Arraylist that contains Structures
- Index(es):
Relevant Pages
|