Get the index of the list with the most items

Hello,

Please help.

I would like to get the index of the list with the most items:

However, list. Indexof (orchard) returns empty , OOTB returns “-1”.

I’ve tried all kinds of lacing and levels etc…

What am I doing wrong?

Thanks.

Is this Revit 2020?

Typically “-1” is the last item on List.

Hope this helps @Dynamo_Ann :


you need to convert it into integer so that comparison will be smoother.

1 Like

Instead of using L2 at your List.Count node, you might wanna use longest lacing instead. If that doesn work, then you will need to flatten it before you do your list.count. If it still doesnt work, then somewhere along the line, the ObjectType of the item inside the list got “mixed up” and hence cant detect which index it is at.

As @shashank.baganeACM mentions, the issue is data types.

Your list cannot find the index of the item ‘128’ as although they look the same, they are not. Trying converting them both to a common data type after getting the max item (using string.from object for example).

The list.indexOf should work as expected then :slight_smile:

1 Like