in reply to Sort array according to a value in each element?

Perhaps you could use Sort::Fields?
#!/usr/bin/perl -w use strict; use Sort::Fields; my @array = ('Item1 - 2 foo, 2 bar', 'Item2 - 0 foo, 1 bar', 'Item3 - 1 foo, 3 bar', 'Item4 - 1 foo, 2 bar' ); my @sorted = fieldsort ['-5n', '-3n'], @array; print "$_\n" for @sorted;