Beat: perverted sort ;)

Beitrag lesen

So das sieht langsam gut aus.

Jetzt stellt sich die Frage, wie \p{L} für > 127 sortiert werden sollen.

#!perl  
use warnings;  
use strict;  
use constant { NL => "\n" };  
  
BEGIN {  
	use CGI::Carp qw(carpout);  
	open(LOG, ">error.txt")  or  die "Unable to append to error.txt: $!\n";  
	carpout(*LOG);  
}  
  
use utf8;  
  
my @unsorted = ( 1.1, 111116, 111107, 'a', '*', '$', '}', '(', 'a27', 'a+', 'a090909', 'a11-11', '1/1', 11.1, '1,1', 10, 0, '1#1', 11, '1)1', 12, '12-', '11-1', '11-', '1a', '1z', '1-1', '1+1', '1-z', '1 1');  
push @unsorted, qw( 23n4n2 232kl1d hallo ä ö ü é zz d\)3 d\)3A 5'5 6'8'8 123.12.22 );  
  
print join NL, SELF::sort(@unsorted);  
<>;  
exit;  
  
#_____________________________________________  
package SELF;  
sub sort{  
	return( map { $_->[0] }  
		sort { $a->[1] cmp $b->[1] }  
		map { [$_, makekey($_) ] } @_  
	);  
}  
  
sub makekey{  
	my $ret = '';  
	foreach( my @a = ( $_[0] =~ /(\d{1,10}|\w+|\W)/g ) ){  
		/^\d/ and $ret .= sprintf("%010d", $_ ) and next;  
		/^\W/ and $ret .= "\x{FFFD}\x{FFFD}" . $_ and next;  
		/^\D/ and $ret .= "\x{FFFD}" . $_ ;  
	}  
	return $ret;  
}  

mfg Beat

--
><o(((°>           ><o(((°>
   <°)))o><                     ><o(((°>o
Der Valigator leibt diese Fische