it sounds like a job for the Schwartzian Transform, but i'm at a loss on how to build the temp array/hash then reconstruct the original.
the values i need to sort on look like this:
I need to sort the array of hashrefs by color, then by size, but since (obviously) S should come before M ... an alpha or ascii sort won't work. i *think* i need a mapping hash also.size: L, color: White size: M, color: Orange size: M, color: White size: M, color: White size: S, color: Orange size: S, color: White size: Xl, color: Orange size: Xl, color: White size: Xl, color: White
i have the regex to get the values out of the string ... but now, how to apply that into a Schwartzian and reconstruct?
where $2 would be the first sort criteria, $1 the second ... so that i end up with ordering like:my $string = $element->{description}; $string =~ m!\w+:\s(\w+),\s\w+:\s(\w+)!;
size: S, color: Orange size: S, color: White size: M, color: Orange size: M, color: White size: M, color: White size: L, color: White size: Xl, color: Orange size: Xl, color: White
In reply to complicated sorting issue by geektron
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |