http://www.perlmonks.org?node_id=903885

gopalr has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I need your help to sort the array content.

The array has following value and the each value has delimitted by '-'.

@array=( 'AC-BA91-CA', 'AB-BA92-CA', 'AD-BA90-CC', 'AA-BA93-CA', 'AA-BA89-CB' )

I need to sort the array by middle of the value. For example, the array output should be the following

@array=( 'AA-BA89-CB' 'AD-BA90-CC', 'AC-BA91-CA', 'AB-BA92-CA', 'AA-BA93-CA' )

I tried to sort by using the cmp and <=>, but I need to sort middle of the value.

Please guide me.

Thanks!!!