How to sorting odd number and even number in the list?


#1

Hello, Dynamo users! :grinning:

I have a simple question.

I’d like to sort odd numbers and even numbers in the list. I am trying to use “List.TakeEveryNthItem” node but the list doesn’t work properly. (Null)

That(curvelt height) is a sigle list, I’d like to seperate (0, 2, 4, 6, …) and (1, 3, 5, 7…). How to handle that problem?

Please help me ! I attached my node and the problem list of node.

Thanks all !


#2

if you see how your TakeEvery node is greyed out. that means it didnt recieve all the required parameters. unfortunately, the n param is not by default (2), so you need to specify that.


#3

I solved this problem !

If i want to sort the even number, first of all, i have to made code block 2; and 1;.

Andthen connect 2; code block to n and 1; code block to offset.

Also, you are right, chrisishere. Thanks for your help. :grinning:


#4

You can use Modulo [%] node for this.

This calculates the remainder for each number in the list divided by 2.