checks if there something in array if so sort