Fix comparator and add logic for arrays copy.