Array comparison in PHP

While working on a recent project, I had to do some array comparison. I did array comparison by doing the following:

According to my requirements the above two arrays are same but if we compare it in PHP, it would not think so due to the presence of value on different indexes. To solve that, I first sorted and then compared these arrays, which gave me the required result.