Sort an array (structure array)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?TWFyaw==?=

    #1

    Sort an array (structure array)

    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



  • =?Utf-8?B?S2VycnkgTW9vcm1hbg==?=

    #2
    RE: Sort an array (structure array)

    Mark,

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

    Kerry Moorman


    "Mark" wrote:
    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
    >
    >
    >

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Sort an array (structure array)

      "Mark" <Mark@discussio ns.microsoft.co mschrieb:
      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>

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

      Comment

      Working...