Update: suggestion about splitting is valid only if the result from database is "|"-separated, as cleverly pointed out here...
You had to say it immediately:
Note that, by default, putting @sorted_strings in double quotes will give you space-separated items. You can change the separator using the perlvar $":my @strings = split /\|/, $status;
I put the curly brackets in order to restrict the modification of the $" variable, making this modification "visible" to the print statement only.{ local $" = "|"; print "<br><font color=red>@sorted_strings</font><br>"; }
Anyway, I'd probably use a more flexible, metadata-based approach:
my %subst ( P => 'Posted', F => 'Posted', C => 'Posted', D => 'Posted', I => 'Posted', A => 'Accepted', N => 'New', R => 'Rejected', S => 'Save', X => 'Canceled', ); my @sorted_strings = sort map { $subst{$_} } split /\|/, $status; # The above line can be roughly expanded to the three lines below: # # my @status_letters = split /\|/, $status; # my @strings; # foreach (@status_letters) { # push @strings, $subst{$_} # } # my @sorted_strings = sort @strings;
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
In reply to Re^3: Sorting Issue
by polettix
in thread Sorting Issue
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |