Sort List PlanrFace

Sort List PlanrFace

ryuzaki2005
Explorer Explorer
296 Views
3 Replies
Message 1 of 4

Sort List PlanrFace

ryuzaki2005
Explorer
Explorer

I have a List of Planrfaces, how can i sort that list in Origin Field? thanks all Pro

0 Likes
297 Views
3 Replies
Replies (3)
Message 2 of 4

jeremy_tammik
Alumni
Alumni

Yes, sure. You can use the generic .NET Sort method and provide an appropriate comparison operator to query the Origin property:

 

https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.sort?view=net-5.0

 

Alternatively, use OrderBy:

 

https://stackoverflow.com/questions/1832684/c-sharp-sort-and-orderby-comparison

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 4

ryuzaki2005
Explorer
Explorer

Thank you sir, but it is still not worrking, even i used this method :

List<PlanarFace> b = (a.OrderByDescending(x => x.Origin.X).ThenBy(x=>x.Origin.Y)).ToList();

0 Likes
Message 4 of 4

jeremy_tammik
Alumni
Alumni

Ah well, research further, keep it simple, continue trying.

  

The Building Coder shares numerous examples of using various comparison operators that you can take a look at and might provide inspiration:

 

https://www.google.com/search?q=comparison+operator&as_sitesearch=thebuildingcoder.typepad.com

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes