Trying to sort a list based on a position and remove repeated elements

Hi all,

I would like to sort this list based on the last digit and get rid off the repeated values. I was trying to split the elements filtering them but I am not sure how can I assembly them together.

See example below.

All suggestions will be more than welcome.

Thanks

R

Post your data!

And with two panels in your screen shot, your question is even less clear?

By the way, though I barely understand your question, I suspect from its nature that you’ve already taken a few “wrong turns” to get to this point and this is an effort to clean up a mess?

1 Like

Removal of repeats can be done with Create Set, at least provided your data is of a ‘simple’ type, such as Text, Numbers, Points. I haven’t actually checked whether it works with paths.

As for the sorting, do you really mean the last digit, or the last number in each path. I.e. what if a path ends in a number which has two or more digits?

I wasn’t reading the panels closely enough but I see the pattern now. The last digits of each row in the second panel are 0, 1, 2, 3, 4, 5. The full values in the second panel are the first occurrence in the first panel ending with that digit.

Thanks Joseph,
Apologize for not posting any script. I tried different options but they did not work, that’s why I posted what I was trying to get. I will really appreciate if you could help me with any suggestion.

By the way, as you said that is exactly what I wanted to explain.

Thanks again,
R

No one wants to recreate your data. You can easily internalize that list of paths in your first panel by right-clicking the Txt component (below) and clicking “Internalize”.

internalize_2019Nov21a
internalize.gh (11.7 KB)

My “spidey sense” tells me that there is a deeper problem that led to this requirement, and that you’d be better off addressing that. I don’t think it does anyone a favor to treat this as routine housekeeping. Helping people clean up messes generally leads to more messy code/data. We’ve all had to go through stuff like this but eventually learn that it’s far better to avoid the “messed up” data trees in the first place.

1 Like

Hi,

this could be one of many possible solutions…

Yeap!

2 Likes

Thank you so much. That was brilliant.
R

Nice, but I see a flaw. Using “2” for the ‘i’ value will work only with paths that have three elements:

flaw

Would be better to either:

  1. use ‘i = -1’ for last or
  2. reverse the ‘L’ input and use the default ‘i = 0’ to get the last element of the path

I have a morbid curiosity about the underlying problem that this exercise is supposed to solve?

3 Likes