in reply to Ordering meta tags with HTML::Element

You can control sorting by putting a sort routine after the sort keyword, e.g.:
for my $m (sort nameFirst ('fred', 'alf', 'tom', 'bert', 'name', 'pete +')) { print "$m\n"; } sub nameFirst { if ($a eq 'name') { -1; } elsif ($b eq 'name') { 1; } else { 0; } }
sort calls your routine to test a pair which arrive in your routine as $a and $b. You can return the values explicitly although it is customary to just auto-evaluate for sort routines. Returning -1 or 1 tells sort what relative position to use for a given pair. 0 means 'evaluate equal or don't care, so leave as is'. The above produces:
name fred alf tom bert pete
update: if you have more complex rules than this, you can drill down to an evaluation subroutine or hash. For example, suppose the order should be name first and aref last
sub nameBlahAref { naeval($a) <=> naeval($b); } sub naeval { $_[0] eq 'name' and return 1; $_[0] eq 'aref' and return 3; return 2; }
The <=> operator compares what is either side of it numerically and returns the required -1, 0 or 1 accordingly.

One world, one people