Can anyone explain the codes below?
# Code1 @s = sort mycriteria @a; sub mycriteria { my($aa) = $a =~ /(\d+)/; my($bb) = $b =~ /(\d+)/; sin($aa) <=> sin($bb) || $aa*$aa <=> $bb*$bb; }
# Code2 @s = sort {($a =~ /(\d+)/)[0] <=> ($b =~ /(\d+)/)[0] || uc($a) cmp uc( +$b)} @a;
How the regular expressions function in the code above??
In reply to Questions on sort by jiashiun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |