Reputation: 9969
i have a list of my g class
Public Class g
Public x as Decimal
Public y As Decimal
End Class
Dim MyQuery As List(Of g) = ...
which i try to sort like
Dim sorted As List(Of g) = MyQuery.OrderBy(Function(x) x.y).ThenBy(Function(x) x.x).ToList()
Unfortunately i get the following error
At least one object must implement IComparable.
What am i doing wrong here? When i try to sort by one property i get no errors
Dim sorted As List(Of g) = MyQuery.OrderBy(Function(x) x.y).ToList()
Upvotes: 0
Views: 1600
Reputation: 174369
The code you provided in your question works as is. Your original code most likely doesn't use decimal
for the properties but some other type that doesn't implement IComparable
, resulting in the exception you get.
Upvotes: 1