Reorder Node
The Cartan Node Library is having a growth spurt. Here is yet another new node...
Reorder takes a list of up to 7 items and reorders it. The items can be anything: strings, numbers paths, points, colors, whatever. If you give it more than seven items it will only work with the first seven.
A limit of seven may seem restrictive, but there are 5040 different ways of reordering seven items. I have found a frequent need to reorder lists of only three or four items. For example, my Sanzo_colors node can output quartets of color and I often want to step through the 24 possible ways of reordering such a quartet.
It's a simple node. Just feed it your list and tell it which ordering you want:
- Order 0 returns the list in its original order.
- Order 1 returns the first permutation, order 2 the second, etc.
- There are n! (n factorial) different possible orders for a list with n items. If you enter an order number greater than the possible number of permutations, reorder will return the final permutation.
- If you give it a list with a single item it will just return that item
The attached demo shows the reorder node receiving strings, numbers, shapes, and colors. Change the value of the integer node named ORDER to see different permutations of those objects.
I also include a subnetwork with reorder inside it that produces a chart showing the 24 different ways of reordering four colored shapes.
Note: in the process of developing this node, I updated an earlier node, orderings, which lives inside the reorder node. The original version of orderings would only accept lists of from 3 to 8 items. The updated version accepts lists of from 1 to 7 items and runs noticeably faster. I will include the updated version of orderings in the next release of my library; if you need it before then you can pluck it from inside the reorder node.
If you want to visit my Instagram account you can see a nifty animation I made using reorder earlier today,
Enjoy!
-
reorder_screenshot.png 673 KB
- reorder_node.ndbx.zip 174 KB
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac