Sort an array (structure array)

G

Guest

Hello,

Suppose I have defined a structure....

Structure RenameDocs
Public Facility As String
Public Document As String
Public Subtitle As String
Public Page As String
End Structure

And then declared an array of this structure...

Public stRenameDocs() As RenameDocs

Through the course of processing, the array becomes populated with data.
Now I need to sort the array by Facility, Document, Subtitle.

I'm at a loss as to how I should approach this. Any suggestions?

Thanks,
Mark
 
G

Guest

Mark,

Have your structure implement IComparable and then use Array.Sort.

Kerry Moorman
 
H

Herfried K. Wagner [MVP]

Mark said:
Suppose I have defined a structure....

Structure RenameDocs
Public Facility As String
Public Document As String
Public Subtitle As String
Public Page As String
End Structure

And then declared an array of this structure...

Public stRenameDocs() As RenameDocs

Through the course of processing, the array becomes populated with data.
Now I need to sort the array by Facility, Document, Subtitle.

See:

<URL:http://dotnet.mvps.org/dotnet/samples/techniques/CompareOperator.zip>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top