How to do 2 sorts in the same arraylist.

Last post 02-06-2009 8:49 AM by DkUltra. 2 replies.

Sort Posts:

  • How to do 2 sorts in the same arraylist.

    02-03-2009, 8:11 AM
    • Member
      12 point Member
    • PascalCmoa
    • Member since 07-18-2008, 8:52 AM
    • Posts 29

     Hi every body

     

    I created a class to sort an arraylist that i used to bind a GridView. In this case i have no problems, in this case i sort my arraylist with the id_user.

    But i don't know how sort this same arraylist with id_user and date, in fact i want te realized a sort with the id_user in the first sort and after with the date, 2 sorts in my arraylist. But i don't know how to do that.

     You may see my class below:

     

    Public Class trieur
    Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
    Dim
    valeurX As modif = CType(x, modif)
    Dim valeurY As modif = CType(y, modif)
    Select Case valeurX.id_User- valeurY.id_User
    Case Is > 0
    Return 1
    Case Is = 0
    Return 0
    Case Else
    Return
    -1
    End Select

    End Function
    End Class
      

     

    PascalCmoa
  • Re: How to do 2 sorts in the same arraylist.

    02-05-2009, 3:51 AM
    • Member
      12 point Member
    • PascalCmoa
    • Member since 07-18-2008, 8:52 AM
    • Posts 29

    No one to help me ??? Crying

    PascalCmoa
  • Re: How to do 2 sorts in the same arraylist.

    02-06-2009, 8:49 AM
    Answer
    • Contributor
      2,663 point Contributor
    • DkUltra
    • Member since 03-19-2007, 10:06 AM
    • South Dakota / Nebraska
    • Posts 521

    A person could use a generic list, which has built in sorting -kindof.

    Check out http://stackoverflow.com/questions/438715/how-sort-a-system-collections-generic-list-in-vb-net

    what about using linq ?

    Hope this helps

    DK

Page 1 of 1 (3 items)