Just a quick one. It would probably be more efficient to run the regexp match only once and transform the list items into somthing like ({str => 'dana', num => 10},...).#!/usr/bin/perl use warnings; use strict; my @list = qw(erez[11] dana[22] dana[0] erez[10] erez[1] erez[0] dana[ +10]); my @sorted = sort sorter @list; print join ' ', @sorted; sub sorter { my ($a_str, $a_num) = ($a =~ /(\w+).(\d+)/); my ($b_str, $b_num) = ($b =~ /(\w+).(\d+)/); return $a_str cmp $b_str unless $a_str eq $b_str; return $a_num cmp $b_num; }
In reply to Re: Sort options
by pjotrik
in thread Sort options
by erez_ez
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |