in reply to Re^10: Sort problems
in thread Sort problems

Hi ikegami, :) Sorry for bugging you, but it keeps printing 2 1 10. I tried to change the regex in different ways but it didnt work. Any advice?

Replies are listed 'Best First'.
Re^12: Sort problems
by ikegami (Patriarch) on Dec 25, 2008 at 09:53 UTC

    No, I'm the one who wasn't paying enough attention or testing his stuff X_X. I wasn't calculating the right length.

    print("$_\n") for map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { my $s = $_; $s =~ s/(?<![\[\d])(\d+)/ sprintf('%010u%s', length($1), $1) /eg; $s =~ s/(?<=\[)(\d+)/ sprintf('%010u', 4294967296-$1) /eg; [ $_, $s ] } do { local $/; split ' ', <DATA> };

    I tested it this time!

      Hi ikegami, It works! Thanks a lot for the effort..