Sorting a VB.net List by a class value

前端 未结 3 925
误落风尘
误落风尘 2021-02-04 00:37

I have a list (i.e. Dim nList as new List(of className)). Each class has a property named zIndex (i.e. className.zIndex). Is it possible

3条回答
  •  攒了一身酷
    2021-02-04 01:13

    You can use a custom comparison to sort the list:

    nList.Sort(Function(x, y) x.zIndex.CompareTo(y.zIndex))
    

提交回复
热议问题