I'm having trouble getting an array to sort correctly. It looks like this...
If I were to sort and print this like this....
It doesn't work out...
1.5_F31 is higher than 1.5_F8, for example. How can I sort this the right way? I guess I'll need to add a zero to any version numbers that only have 1 digit after the letter so 1.5_F8 would temporarily become 1.5_F08. Then it would get sorted, and before its printed any added 0's will need to be removed. Any ideas on how to go about this?
Thanks!
--
Chris
RHCE, SCSA, AIX5L, LPIC, CNE, CCNA, MCSE
Code:
@unsorted = (
'1.0_A0 - name - Aug 01 2006 08:50',
'1.4_E3 - name.10 - Mar 07 2007 16:55',
'1.5_F1 - name.11 - Mar 23 2007 18:17',
'1.5_F8 - name.15 - Sep 12 2007 17:16',
'1.5_F10 - name.16 - Sep 12 2007 17:27',
'1.5_F12 - name.17 - Sep 26 2007 17:15',
'1.1_B0 - name.2 - Aug 07 2006 10:00',
'1.5_F30 - name.28 - Mar 10 2008 17:56',
'1.5_F7 - name.14 - Sep 11 2007 17:16',
'1.5_F31 - name.29 - Apr 25 2008 17:43',
'1.2_C2 - name.3 - Oct 02 2006 09:17',
'1.3_D1 - name.5 - Dec 01 2006 17:31'
);
If I were to sort and print this like this....
Code:
@sorted = sort @unsorted;
print "$_\n" for @sorted;
It doesn't work out...
Code:
1.0_A0 - name - Aug 01 2006 08:50
1.1_B0 - name.2 - Aug 07 2006 10:00
1.2_C2 - name.3 - Oct 02 2006 09:17
1.3_D1 - name.5 - Dec 01 2006 17:31
1.4_E3 - name.10 - Mar 07 2007 16:55
1.5_F1 - name.11 - Mar 23 2007 18:17
1.5_F10 - name.16 - Sep 12 2007 17:27
1.5_F12 - name.17 - Sep 26 2007 17:15
1.5_F30 - name.28 - Mar 10 2008 17:56
1.5_F31 - name.29 - Apr 25 2008 17:43
1.5_F7 - name.14 - Sep 11 2007 17:16
1.5_F8 - name.15 - Sep 12 2007 17:16
1.5_F31 is higher than 1.5_F8, for example. How can I sort this the right way? I guess I'll need to add a zero to any version numbers that only have 1 digit after the letter so 1.5_F8 would temporarily become 1.5_F08. Then it would get sorted, and before its printed any added 0's will need to be removed. Any ideas on how to go about this?
Thanks!
--
Chris
RHCE, SCSA, AIX5L, LPIC, CNE, CCNA, MCSE