perldoc perlop...
Binary "<=>" returns -1, 0, or 1 depending on whether the left argument is numerically less than, equal to, or greater than the right argument. If your platform supports NaNs (not-a-numbers) as numeric values, using them with "<=>" returns undef. NaN is not "<", "==", ">", "<=" or ">=" anything (even NaN), so those 5 return false. NaN != NaN returns true, as does NaN != anything else. If your platform doesn't support NaNs then NaN is just a string with numeric value 0
...
Binary "ne" returns true if the left argument is stringwise not equal to the right argument.
Binary "cmp" returns -1, 0, or 1 depending on whether the left argument is stringwise less than, equal to, or greater than the right argument.
perl -le 'print sort {$a ne $b} split //, "<WORT>"'
1
2
my @list = qw(b1 a2 s3 s4 i5 s6 t7);
my @tsil = sort {substr($a, 0, 1) ne substr($b, 0, 1)} @list;
perldoc -f sort...
Perl 5.6 and earlier used a quicksort algorithm to implement sort. That algorithm was not stable, so could go quadratic. (A stable sort preserves the input order of elements that compare equal. Although quicksort's run time is O(NlogN) when averaged over all arrays of length N, the time can be O(N**2), quadratic behavior, for some inputs.) In 5.7, the quicksort implementation was replaced with a stable mergesort algorithm whose worst-case behavior is O(NlogN). But benchmarks indicated that for some inputs, on some platforms, the original quicksort was faster. 5.8 has a sort pragma for limited control of the sort. Its rather blunt control of the underlying algorithm may not persist into future Perls, but the ability to characterize the input or output in implementation independent ways quite probably will. See the sort pragma.
...
Guest Wastl@Linuxer
Stimmt, die fehlende -1 könnte auf jeden Fall ein Grund für das seltsame Verhalten sein.
Quote@Muffi
Na ja, so ganz schlechter Zufall kann das nicht sein. Sortiert man auf diese Weise bassist, ferrari oder 1255354 erhält man folgendes Ergebnis:
Code: (dl )perl -le 'print sort {$a ne $b} split //, "<WORT>"'