We can not use sort function because the array contains objects.