second attempt at sort