Added pixel sorting