Sorting lists



I’m having trouble sorting lists. I have lists of four items, and across all lists, want to switch positions of items 2 and 3. It would seem that the use of a simple {0,1,3,2} sort would give the desired result, yet all I am able to do is switch the lists within the greater list, and not the items themselves. Can anyone point me in the right direction?

Please see the attached screen cap.


140617_list sort


Hi Alex,

What you’re looking for is the list map functionality, which will allow you to apply some function–say, swap the third and fourth items–to a lower level of hierarchy in the list. The basic scheme is this:

where I made a custom node that looks like this:

The setup for version 0.7.1 would be about the same, by the way, but the custom node can be even simpler, using just a single Code Block Node:

A good strategy when making these things is to make your algorithm work for a simple case, wrap it in a custom node (by selecting a group of nodes, right clicking in the canvas, and choosing “New Node From Selection”), and then use the List Map node to apply it to a deeper level of your list.