PDA

View Full Version : Advanced Array Sorting


wkdown
07-29-2008, 04:35 PM
REFERENCE LINK: http://hopepublishing.com/html/main.isx?sitesec=40.1.0.0&TermsAccept=yes

I have a somewhat unique question. The dropdowns in this form are populated by a database pull, so they are held on the backend as an array of arrays. I want to numerically sort the 'Meter' field, so I used the following:

@meterRecords = sort { $a->[1] <=> $b->[1] } @meterRecords;

While this works fairly well, as you can see, there is still an issue due to the period-separated values beyond the second element. I was considering spliting on the period into an array and somehow sorting the resulting three-dimensional array, but I think there must be a more efficient way. Does anyone have any suggestions?

(BTW, I'm pretty handy with other languages, so if you don't know Perl, provide your suggestion in your native tongue)

KevinADC
07-30-2008, 12:39 AM
Make it easy to help you. Show the data, explain the data, show how you want it sorted.