Houdini 20.5 Nodes Geometry nodes

Sort geometry node

Reorders points and primitives in different ways, including randomly.

On this page

Overview

In Houdini, points and primitives have an inherent order, and each point/primitive knows its own “point number” or “primitive number” (its index within the list of points/primitives). This node lets you change the order of points/primitives based on certain criteria.

To change the order of vertices within a primitive, use the Reverse SOP instead.

Sorting by an arbitrary expression

Do not use this node to sort “by expression” (setting the Point Sort parameter to By Expression). Instead, do the following:

  1. Use Attribute Create or Attribute Wrangle to set an attribute on each point/primitive with a “comparison key” value that can be used to order each element.

  2. Use the Sort node to sort “by attribute” using the key attribute.

This has two advantages over sorting “by expression”:

  • You can view the attribute contents in the geometry spreadsheet to make sure you are generating the right values.

  • It is usually much faster, since sorting by attribute can be multi-threaded, but expressions with local variables cannot.

Note

The Sort SOP does not properly sort Vector3/Vector4 values or arrays - it only sorts by a single component. However, because the Sort SOP uses a stable sort, you can wire together multiple Sort nodes to sort by multiple components or attributes.

Locals

This node does not have any special local variables. You can use the common local variables when sorting “by expression”. However, see sorting by arbitrary expression above.

Parameters

Point Group

The points to sort. Only these points will be re-arranged by the point sorting choices.

Point Sort

How to sort the elements.

No Change

Do not change the order (preserve the current order).

By Vertex Order (points only)

Sort points to match the order of the vertices on the primitives they belong to.

If you have a curve whose point numbers don’t increase along the curve, this will give the points the proper numbers.

By X/Y/Z

Sorts by the element’s X, Y, or Z coordinate.

Reverse

Reverses the current ordering.

Random

Scrambles the elements into a random order.

NOTE: Does not currently support restriction to a group.

Shift

Shifts the current element numbers forward by a certain offset. Point numbers at the end of the point list wrap around to the start.

Proximity to Point

Orders the elements by how close they are to a certain point.

This can be useful for limiting a point cloud to only the N closest points to a target: sort the points by proximity, then delete all but the first N points.

Along Vector

Orders the elements by their position along a certain line in 3D space. This is similar to “By X/Y/Z” but lets you specify an arbitrary line instead of one of the cardinal axes.

By Expression

This option lets you sort elements using “key values” generated by an expression. However, it is faster and more convenient to use attributes.

Spatial Locality

Changes the order so elements that are near to each other in 3D space have similar numbers.

By Attribute

Uses the value of an attribute as a “key value” to sort by. For Vector3/Vector4 attributes, the node can only sort by a single component at a time. However, because the Sort SOP uses a stable sort, you can wire together multiple Sort nodes to sort by multiple components, or multiple attributes.

Seed

When the sort method is “Random”, the seed to use for the random number generator. Different seeds will generate different random orders.

Offset

When the sort method is “Shift”, the number of places to shift the element numbers forward.

Point

When the sort method is “Proximity”, order the elements by how close they are to this point.

Vector Object

When the sort method is “Along Vector”, if you enter a path to an Object node here, the Sort node will use that objects translate as the vector to sort along.

This lets you sort along a vector from the origin to the object’s current 3D position.

Vector

When the sort method is “Along Vector”, the vector to use for sorting. This vector is signed, so a value of 0, 1, 0 is the equivalent of sorting By Y, while 0, -1, 0 is the reverse.

Expression

When the sort method is “By Expression”, this is the per-element expression to use to generate key values. However, it is faster and more convenient to use attributes.

Attribute

When the sort method is “By Attribute”, the name of the attribute to use a the sorting key.

Component

When the sort method is “By Attribute”, which component of a compound (vector/matrix) value to use as the sorting key. The Sort node can only sort by a single component at a time. However, because the Sort SOP uses a stable sort, you can wire together multiple Sort nodes to sort by multiple components, or multiple attributes.

Reverse Point Sort

Reverses the sorted ordering computed by the controls above. For example, if you set the sort method to “By X” and turn this on, points are sorted by decreasing X positions.

Primitive Group

The primitives to restrict the sort to. Only these primitives will be re-arranged by the primitive sorting operation.

Primitive Sort

See the help for Point sort above.

Reverse Primitive Sort

Reverses the sorted ordering computed by the controls above. For example, if you set the sort method to “By X” and turn this on, primitives are sorted by decreasing X positions.

Optimize Internal Vertex Order

Sort vertices according to the primitive number and vertex order in each primitive. This will affect the linear vertex index used by VEX functions like vertexindex, vertexprim, and vertexprimindex.

Geometry nodes