careerquiz
Technical User
Hi everybody,
I have a really stupid sort problem that I haven't been able to figure out. Although, not entirely a novice I've just spent 4 hours trying to sort an array.
Okay here it is:
I have a database.txt file with a header row such as
name|address|category
John|122 Mockingbird|Tools
Okay, I'm using a small script to search the file and pull out matching terms and then place them in a template.
If I sort the using a sort such as
@lines = sort { $a cmp $b } @lines;
the script hangs for awhile then crashes. If I use a reverse sort such as
@lines = sort { $b cmp $a } @lines;
the script completes but the results are in decending order. This is driving me nuts. I'm sure it's something stupid. I think it may have something to do with the header row but not sure. Could really use someones help on this one. I've attached the script to this message. Thank you for your time.
I have a really stupid sort problem that I haven't been able to figure out. Although, not entirely a novice I've just spent 4 hours trying to sort an array.
Okay here it is:
I have a database.txt file with a header row such as
name|address|category
John|122 Mockingbird|Tools
Okay, I'm using a small script to search the file and pull out matching terms and then place them in a template.
If I sort the using a sort such as
@lines = sort { $a cmp $b } @lines;
the script hangs for awhile then crashes. If I use a reverse sort such as
@lines = sort { $b cmp $a } @lines;
the script completes but the results are in decending order. This is driving me nuts. I'm sure it's something stupid. I think it may have something to do with the header row but not sure. Could really use someones help on this one. I've attached the script to this message. Thank you for your time.