fixing issues in array sorting with breaks some tests