distance calculation for sort and more css