Ahh...I missed that. Now that I have that part corrected...I have tried to sort using both cmp and <=>...both are returning the same results which is:
2008-03-24
New 1 Month Subscription 1
New 12 Month Subscription 5
New 14 Day Trial Subscription 3
New 6 Month Subscription 6
I understand that is it using the ASCII value to sort right now, which is not what I want. How can I get it to sort the string part and then the numbers as numbers?
Thanks again...
Quote:
Originally Posted by KevinADC
This line is wrong:
- foreach my $name ( sort {lc($data{$a}) cmp lc($data{$b})} keys %{
should be:
- foreach my $name ( sort { $data{$this_date}{$a} cmp $data{$this_date}{$b} } keys %{ $data{$this_date} } ) {
but don't expect 6 to come after 12 when you sort using "cmp" because the sort is what is called asciibetical (sort of like alphabetical), in which case 12 comes before 6 like 'AC' comes before 'D'.
Note: there is no need to use lc() in your sort because all the characters are the same mix of upper and lower case characters. Use lc() or uc() when the strings being sorted are not all the same case.