How sort a System.Collections.Generic.List in VB.Net?

前端 未结 4 1339
悲&欢浪女
悲&欢浪女 2021-01-31 09:23

I using a genric list(m_equipmentList ) which is collection of objects (Schedule_Payitem).
How can sort list according to a proerty of child object ?

Dim m_         


        
4条回答
  •  爱一瞬间的悲伤
    2021-01-31 09:52

    You can accomplish sorting the list in descending order by changing this-

    m_equipmentList.Sort(
    Function (ByVal payItem1 As Schedule_Payitem, ByVal payItem2 As Schedule_Payitem) 
        Return payItem1.ResourceID.CompareTo(payItem2.ResourceID)
    End Function)
    

    to this

    m_equipmentList.Sort(
    Function (ByVal payItem1 As Schedule_Payitem, ByVal payItem2 As Schedule_Payitem) 
        Return payItem2.ResourceID.CompareTo(payItem1.ResourceID)
    End Function)
    

提交回复
热议问题