Tuesday, January 08, 2008

compare arrays

I've seen many different functions which compare arrays, so I've decided to write my variant of this function. I suppose my function much simpler.

here is the script o function

Function ArraysAreEqual (vA As Variant, vB As Variant) As Variant

Dim rez As Variant

rez = Evaluate({@implode(@sort(@Explode("} & Join(vA, "~") & {"; "~")); "~") = @implode(@sort(@Explode("} & Join(vB, "~") & {"; "~")); "~")})

If rez(0) = 0 Then ArraysAreEqual = False Else ArraysAreEqual = True

End Function


advantages of my approach:
- more simple, just 1 line;
- faster;
- we can compare any number of arrays

but any advices will be appreciate! especially disadvantages !

3 comments:

  1. Hi I have used your code and it has worked like a charm. Thank you for sharing it.

    ReplyDelete
  2. Anonymous12:39 PM

    great code it's simple and works

    ReplyDelete
  3. Anonymous8:38 AM

    thank you for this code! It's great.

    ReplyDelete