It's a very easy problem but can't get my way around it. I have an array of hashes. The data structure as follows:
my @unsorted = (
{
'key_5' => '14.271 text',
# ...
},
{
'key_5' => 'text',
# ...
},
{
'key_5' => '13.271 text',
# ...
},
{
'key_5' => 'etext',
# ...
},
);
How can I sort the array based on key_5 of the hash. The string part should be sorted alphabetically. and where the key is number string (format is always like this),it should be sorted numerically (ignoring the string part completely). So the output would look like, either:
my @sorted = (
{
'key_5' => 'etext',
# ...
},
{
'key_5' => 'text',
# ...
},
{
'key_5' => '13.271 text',
# ...
},
{
'key_5' => '14.271 text',
# ...
},
);
So, the array elements are sorted based on key_5 of the hash elements.
Important: Cannot use any perl packages that are not shipped with native perl installation. Using perl 5.18