re-wrote sort routine to use blocks