| Article | 70002393 |
| Type | HowTo |
| Product | Engine |
| Version | 10 |
| Date Added | 8/4/2023 12:00:00 AM |
| Fixed | 10.1004.0.6 (8/4/2023 12:00:00 AM) |
| Submitted by | Ahmed Anas |
Summary
I have gpoints containing following points. (5,0,10) (33,0,66) (0,0,0) (15,0,30) (20,0,40) (28,0,56) (24,0,48) (10,0,20) Now is there a quick way to arrange them in ascending order as shown below through a line. I.e. (0,0,0) (5,0,10) (10,0,20) (15,0,30) (20,0,40) (24,0,48) (28,0,56) (33,0,66)
Solution
Example:
gPoints pts = new gPoints(new gPoint[] {
new gPoint(5,0,10),
new gPoint(33,0,66),
new gPoint(0,0,0),
new gPoint(15,0,30),
new gPoint(20,0,40),
new gPoint(28,0,56),
new gPoint(24,0,48),
new gPoint(10,0,20)
});
pts.Sort(new sortgpointsX());
class sortgpointsX : IComparer
{
public int Compare(gPoint x, gPoint y)
{
if (x.x == y.x) return 0;
if (x.x > y.x) return 1;
return -1;
}
}
