Looking for help understating Lists, list.map and how to map a list

Hi all,

I’m having some issues understanding list.map. I’m trying to match a new list with the original list, making sure that the values on list A match list B and if they don’t I will like them to be sorted so list B follows list A.
I’m attaching a screenshot of the original list, the list to be mapped with original, what it looks like the sorted list and the new keys.
On the sorted new list I notice that the order is incorrect and doesn’t follow list a.

Welcome to the forum!

List.Map is for mapping a function to a list of inputs, like you did with GetItemAtIndex. All you’re wanting to do is sort List B to match List A. That’s just a comparison of elements.

First, I would ask why you need to sort List B to match List A when they already contain the same elements? Why do you need two of List A? If you have a complementary list of objects that also need to be sorted (which is why I would guess you’re using SortByKey) then that makes sense, if you don’t, then you could just use List A.

I would recommend starting with an == comparison of each item in List A with each item in List B. Use list levels to check the entirety of List B against each individual item in List A, then use FilterByBoolMask to filter the matches for each item. If you do have complimentary objects that need sorted/filtered then you can filter that list as well.

To understand better what you’re trying to achieve, can you give a quick example what you expect the maps list to look like.

Hi @Nick_Boyts, thanks for replying!

List A is the original order of the lines drawn in the background. List B was created after splitting the lines from list A into negative and positive vectors. What I would like to do is put them back into a list following the original order.
I followed your advise on starting with comparison and I got this:


Do you need the current list structure of individual sublists? This would be much easier with a flattened list. Either way, the important part is using list levels like I mentioned to ensure that each item in List A is being compared against every item in List B. Right now you’re just comparing the same items at the same indices. You would then also have to use list levels on FilterByBoolMask to filter each sublist against the original list.

Thanks for helping out, the solution was looking into == . That was the route I need it to go comparing List A and List B and filtering with a cross product

1 Like