Seems like this should be very simple; I have a 2D array:
[["Apple",123],
["Berry",234],
["Cherry",345],
["Dog",456]]
I have a list:
["Apple","Dog"]
I would like to return an array based on the list items:
[["Apple",123],
["Dog",456]]
Note: the real 2D array has 100 rows and 10 columns. Thanks !
Bonus, a command that will filter to just "Apple" and "Dog" rows as well as "Product" and "Quality" columns:
[["Product","Quantity","Quality"],
["Apple",123,"Red"],
["Berry",234,"Blue"],
["Cherry",345,"Choke"],
["Dog",456,"Big"]]
Expected result:
[["Product","Quality"],
["Apple","Red"],
["Dog","Big"]]
or
[["Apple","Red"],
["Dog","Big"]]
Again, the order and number of columns and rows is variable.
Update:
Based on the two answers below, neither filtering approach seems to work for my use-case. As such, I will provide the following context. Rather than "Products" like "Apple" and "Dog", my array is more like:
[["URL","Quantity","Quality"],
["http://abcd.defg.eghi.com/alphabet/abcd1234-ef12-23ed-eafe/q?key=123-abc",123,"Red"],
["http://abcd.defg.eghi.com/alphabet/aecd934-ef12-23ed-jufe/q?key=176-abc",234,"Blue"],
["http://abcd.defg.eghi.com/alphabet/eafcd134-ef24-23ed-eefe/q?key=145-abc",345,"Choke"],
["http://abcd.deeg.eghi.com/alphabet/abcd1234-ef12-23ed-45fe/q?key=187-abc",456,"Big"]]
and my list is like:
["http://abcd.defg.eghi.com/alphabet/abcd1234-ef12-23ed-eafe/q?key=123-abc","http://abcd.deeg.eghi.com/alphabet/abcd1234-ef12-23ed-45fe/q?key=187-abc"]
My expectation is that the first and fourth row would be returned, as with Apple and Dog, but for some reason the URLs aren’t filtering. Are there any special characters that may be affecting this function ?
2
Answers
Based on yout second use case. You can use various of Array functions to achieve it. Here’s an example: