Fixed issue in logical comparison for sorting.