Sort Array of Object
Class CompareEmployeeID : Implements IComparer
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
Dim xEmployee As Employee = DirectCast(x, Employee)
Dim yEmployee As Employee = DirectCast(y, Employee)
Return New CaseInsensitiveComparer().Compare(xEmployee.SSNumber, yEmployee.SSNumber)
End Function
End Class
Dim objEmployeeArray() = objEmployeeList.ToArray
Array.Sort(objEmployeeArray, New CompareEmployeeID)
No comments:
Post a Comment