Comparing Array Lengths

Background
A Customer purchases an expansion pack from our website and an API updates the expansion code. I’m comparing the Users Expansions on the API with the Expansions purchased to make sure everything is updated. I created two arrays to compare

I’m using the Array operators: Array length equal to. As you can see from the attached image, the Arrays are not equal to each other, yet the filter passed it.

What is a better Filter to use in order to compare two arrays to make sure they both have the exact same values, because in this example, the filter should have not passed.

Array Not Equal

I think I figured it out:

  1. Make some more Variables and call them Array1 and Array2
  2. Sort the Arrays by asc so that all of the values in the array are ascending.
  3. Convert the Arrays into a Base64 encode
  4. Compare to make sure the values are equal

Hello there @jmacman :wave:

just wanted to quickly jump in and pat you on the back for the amazing job with figuring out what was wrong with your scenario. We love to see when Makers come up with the solutions by themselves!

Thank you for getting back here and sharing it with us it helps keeping the community clean. :pray:

1 Like

Good solution @jmacman ! The conversion to Base64 is something I didn’t think of immediately haha.
I had to do this a few times as well, and did something similar (if you are interested):

  1. Sort the arrays in the same way (asc)
  2. join() each array with some delimiter, for example a comma or hastag etc.
  3. Now the arrays are a string, you can compare them with the “equals” comparison

Have fun automating!

1 Like

Yep that would work too. I was just experimenting, but the cool this is the Base64 can exactly encode and decode any amount of text even arrays…I thought about making them text with comma delimited as well, but I think so far the Base64 has been working so far.

Thanks for the input!

2 Likes