Sort & SortIndices still a thing?

I'm looking at the Help documentation for Generative Components 10.06.00.93) and it points to simple sorting routines using Sort() and SortIndices().

However I don't see these listed as built-in functions - am I missing something or is the help outdated?

Short of writing an all out sorting function, is there a shorthand route to sorting a random point list, by it Z values?

Parents
  • Hi Robert,

    Those functions are now available as list methods. However, you can still use them as a global function. 

    There are two ways of sorting.

    1. By query expression- from pt in RandomPoints orderby pt.Z
      It will sort in ascending order. If we want to sort it in descending order, we need to add the keyword descending at the end of the expression.
    2. By Sort function - Sort(RandomPoints, function( Point A, Point B){return A.Z< B.Z;})

    We can use the above expression in an expression node.
    Please have a look at the sample example https://communities.bentley.com/cfs-file/__key/communityserver-discussions-components-files/360/SortedPoints.gct. 

    Answer Verified By: Robert Jones 

Reply
  • Hi Robert,

    Those functions are now available as list methods. However, you can still use them as a global function. 

    There are two ways of sorting.

    1. By query expression- from pt in RandomPoints orderby pt.Z
      It will sort in ascending order. If we want to sort it in descending order, we need to add the keyword descending at the end of the expression.
    2. By Sort function - Sort(RandomPoints, function( Point A, Point B){return A.Z< B.Z;})

    We can use the above expression in an expression node.
    Please have a look at the sample example https://communities.bentley.com/cfs-file/__key/communityserver-discussions-components-files/360/SortedPoints.gct. 

    Answer Verified By: Robert Jones 

Children
  • Hi Anik,

    Thanks for the help - I have seen this example before, so knew it could be done, but lock-down must be shutting off parts of my brain.
    The query expression should work fine for my needs.

    However, I don't see Sort and a few others of the list functions like Add, AddFrom, Difference, etc. in the Expression Builder list, or in inteli-sense when trying to write the notation. So was having a hard time recognising how to implement what I see in the help documentation in an actual Node.

    Other List functions like FilledList, Interleave, Series, etc are displayed, so I know they are accessible.