I am using below test method to check whether the Arraylist is sorted as expected.
  @Test
  void compareFields()
  {
    Assignment14 assignment14 = new Assignment14();
    ArrayList<Person> PeopleList = new ArrayList<Person>();
    PeopleList.add(new Person("Alex",56));
    PeopleList.add(new Person("Thomas",23));
    PeopleList.add(new Person("John",10));
    ArrayList<Person> actualSortedResult = assignment14.compareFields(PeopleList);
    ArrayList<Person> expectedSortedResult = new ArrayList<Person>();
    expectedSortedResult.add(new Person("Alex",56));
    expectedSortedResult.add(new Person("John",10));
    expectedSortedResult.add(new Person("Thomas",23));
    Assert.assertEquals(expectedSortedResult, actualSortedResult);
  }
But although the expected and the actual are similar an error is occuring as fellows.
java.lang.AssertionError: expected: java.util.ArrayList<[Person{name='Alex', age=56}, Person{name='John', age=10}, Person{name='Thomas', age=23}]> but was: java.util.ArrayList<[Person{name='Alex', age=56}, Person{name='John', age=10}, Person{name='Thomas', age=23}]>
Expected :java.util.ArrayList<[Person{name='Alex', age=56}, Person{name='John', age=10}, Person{name='Thomas', age=23}]> 
Actual   :java.util.ArrayList<[Person{name='Alex', age=56}, Person{name='John', age=10}, Person{name='Thomas', age=23}]>
<Click to see difference>
I have tried the below assertion types but nothing worked.
   assertTrue("check equality", Arrays.equals(expectedSortedResult.toArray(), actualSortedResult.toArray()));
   Assert.assertEquals(expectedSortedResult, actualSortedResult);
   assertEquals(expectedSortedResult, actualSortedResult);
   assertTrue(expectedSortedResult.equals(actualSortedResult));
   assertArrayEquals(expectedSortedResult, actualSortedResult);
Can I know what is wrong with my method or what should be done?
 
     
     
    