To sort the list of any objects, you must write a class to implement the icomparer (of T) interface and the compare method,
In this example, we use the list of system. Drawing. point as an example to write an upcomparerpoint class for storing the point set in the list."Y"Sort from small to large
Of course, you can write your own classes to sort your class objects. Here is an example for your reference.
The usage is as follows:
Dim Ppoints as new list (of point)
Use Ppoints. Add to add the point to be compared
Then Ppoints. Sort (New upcomparerpoint)
The point set in Ppoints is"Y"Sorted from small to large
imports system. drawing
'''
''' this class implements system. drawing. point compare method, which can be used to add a point to the list, perform sort
'''
'''
public class upcomparerpoint
implements icomparer (of point)
'''
''' implements the compare method for icomparer
'''
''' compared X objects
''' compared y objects
'''
'''
public function compare (byval X as system. drawing. point, byval y as system. drawing. point) as integer implements system. collections. generic. icomparer (of system. drawing. point ). compare
If X. y> = y. Y then
return 1
else
return-1
end if
end function
end class