String padding

String.PadLeft node didn’t do its job. Why?

@Andrej ,

what are you trying exactly ?

KR

Andreas

I want to find the best way for sorting lists by element position (Z>X>Y).

@Andrej ,

you can also use transpose…

what is the disered result?

KR

Andreas

@Draxl_Andreas

Take a look a this post:

I’m using similar approach to set the marks of doors.

You mean you don’t like the idea of List.GroupByKey > List.SortByKey > List.GroupByKey > List.SortByKey > List.GroupByKey > List.SortByKey?

I am guessing this is a display bug, and that the strings have had the 0 character added. Try adding a “-“ instead to see if that displays correctly. If so, proceed with the current value into a + node (or two) and you should be all set. :slight_smile:

2 Likes

The quick solution would be to use numbers then and not strings. Strings won’t sort the way you want without all the extra effort that you’re seeing.

2 Likes

So three rounds of group by key sort by key nodes. :stuck_out_tongue:

1 Like

Well… yeah! :laughing:

If I understand the issue, it’s that strings need to be the same length to sort naturally. Which wouldn’t be a problem for numbers. Dealing with 3 sets of values (x, y, z) is still an issue for strings same as it is numbers, they just have different solutions. In my mind, the more “logical” approach is often a better option than the purely “shortest” approach. Even then, the three sets of Group/Sort probably ends up being fewer nodes than dealing with strings at this point.

2 Likes

Yes I agree. Turns out, my dirty solution is the shortest. I tested it, it works as expected :joy:
I made a single number out of three numbers (Z,Y,X).

a = Z * 100000000 + Y * 10000 + X * 1

and then I just sort by key a.

I could have used

a = Z * 100 + Y * 10 + X * 1

Hypothetically, there could be a situation where the number doesn’t describe the Z>Y>X priority (1 * 100 + 1 * 10 + 0 * 1 would be the same as 0 * 100 + 10 * 10 + 10 * 1). So the more zeros I put in the formula, the less there is a chance that something like that would happen.

Someone should make SortByKey node which allows you to add as many keys as you want…:smiley:

I don’t understand GroupByKey>SortByKey>GroupByKey>SortByKey.

How is the second step not ignoring the previous one?

This works:

Hola amigo @Andrej buenas. not sure to understand what criteria you want to use to sort your list, but you can get the numeric values of x, y and z from a point whit the node .X, .Y, .Z, then you use sort by values to get a list of sorted index by values from the smallest to largest, and then use Get Item at index to reorder the list the points sorted already, i let you an example, if you have elements in the same point and you want to grouping elements by his origin use the node unique items and then all indices of to grouping the matching points, i hope this helps you!

You have to respect the list structure, otherwise you’re right, it would just override the previous sorting. This is why you have to group after each sort. Sorting X values is only necessary for points with equal Y values and sorting Y values is only necessary for points with equal Z values. Grouping ensures that you maintain these equivalences and then list levels ensures that you sort within the group. This results in a multi-dimensional list (that you can flatten at the end) that respects the individual X, Y, and Z sortings.

2 Likes

Careful with this… as the values for Z and Y approach or become less than 0 you’ll get incorrect sorting.