in reply to Unexpected chomp behavior

chomp doesn't return the chomped lines, they're modified "in place". It does, however, return the number of characters removed — which is what you're passing to the sort function in the second case, while you're discarding that value in the first case.