# Compare 2 Arrays of class

**URL:** <https://forum.crystal-lang.org/t/compare-2-arrays-of-class/4198>\
**Category:** Help & Support\
**Created:** [December 28, 2021, 11:03pm UTC](https://forum.crystal-lang.org/t/compare-2-arrays-of-class/4198 "2021-12-28T23:03:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fulgurance](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fulgurance/32/1463_2.png) [@Fulgurance](https://forum.crystal-lang.org/u/Fulgurance)\
**Post date:** [December 28, 2021, 11:03pm UTC](https://forum.crystal-lang.org/t/compare-2-arrays-of-class/4198/1 "2021-12-28T23:03:04Z")

</div>

Hello, today I have a problem in my project, I would like to check if 2 arrays of SoftwareDependency class have the same content, but I have this error:

```auto
if nextDependenciesArray.sort == currentDependenciesArray.sort
                            inextricableDependency = true
                            inextricableArrayTest = currentDependenciesArray
                            break
                        end

```

```auto
 zohran   master  ~  ISM  1  crystal Main.cr -so -i libstdc++-pass1 gcc-pass1
Showing last frame. Use --error-trace for full trace.

In /usr/lib64/crystal/slice/sort.cr:199:12

 199 | v = v1 <=> v2
              ^--
Error: undefined method '<=>' for ISM::SoftwareDependency

```

All array are Array(ISM::SoftwareDependency).

And Is it possible to perform a uniq! in an array like that as well ?

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [December 28, 2021, 11:05pm UTC](https://forum.crystal-lang.org/t/compare-2-arrays-of-class/4198/2 "2021-12-28T23:05:58Z")

</div>

You should look into including [Comparable(T) - Crystal 1.2.2](https://crystal-lang.org/api/Comparable.html) into your `ISM::SoftwareDependency` type.

---

<div class="post-metadata">

**Author:** ![RespiteSage](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/respitesage/32/793_2.png) [@RespiteSage](https://forum.crystal-lang.org/u/RespiteSage)\
**Post date:** [December 29, 2021, 4:02pm UTC](https://forum.crystal-lang.org/t/compare-2-arrays-of-class/4198/3 "2021-12-29T16:02:00Z")

</div>

To clarify, the issue isn’t with your arrays, it’s that you don’t have a way to compare your `ISM::SoftwareDependency` instances.

---

<div class="post-metadata">

**Author:** ![Fulgurance](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fulgurance/32/1463_2.png) [@Fulgurance](https://forum.crystal-lang.org/u/Fulgurance)\
**Post date:** [December 29, 2021, 5:40pm UTC](https://forum.crystal-lang.org/t/compare-2-arrays-of-class/4198/4 "2021-12-29T17:40:37Z")

</div>

I solved my problem finally with an another way, and it was better, sorry if I didn’t replied directly, I’m busy with my project actually. Thanks you so much for your help !
