Sort component bug? - changes null to 0

null casts to 0 when going through a sort component.

image

Is this a feature or a bug?

I was expecting the null not to sort, or to return a null in the sorted list. It’s not really a problem b/c the concurrent sort preserves it, but it tripped up my workflow recently so I thought I’d ask.

Thanks!

using Rhino Version 6 SR16
(6.16.19169.11231, 06/18/2019)

Use replace null or combine data

Yes, either would be a work-around.

I’m wondering whether there is any case where this behavior would be desired/intended, or if it’s a bug.

Sorts description is “Sort a list of numeric keys” numeric being the key word, in most cases when you input a data that is not the data the component needs, it gets cast best it can. Similar to plugging a surface into an input that needs a curve, the surface will get cast to curves as its edge curves. In this case there isn’t a way to sort nulls vs numbers (should nulls go to top of list, bottom, stay where they are?), and nulls are not necessarily numbers, a null can represent any geometry type, so it being zero allows it to be used by the sorting algorithm. Probably a case can be made to keep nulls but it would require options on what to do with them I think.

That all makes sense.

I hadn’t really considered the alternatives - what would happen to the nulls, or where they would go otherwise.

In other cases where nulls have been cast to 0, like the arithmetic operators and boolean operators , there was a clear and preferable alternative. As far as alternatives to this problem go, none of the options you suggest (first, last, or leave in place) seem conclusively better. At least the cast to zero behavior is predictable.

Thanks!