Problems? Is your data what you think it is? | |
PerlMonks |
Re^6: Sorting an array of hashes with an exeptionby martin_87 (Initiate) |
on May 10, 2013 at 16:29 UTC ( [id://1032981]=note: print w/replies, xml ) | Need Help?? |
Sorry if I made the last post seem angry but I'm tired and a bit frustrated atm. Not my intention at all to sound mad at you directly. So the problem that I have is the following. I'm receiving an hash from an XMLpost. This hash contains alot of information but the only parts that I need is ID, Name, Distance and RouteDistance. I have not mentined Name before but it does not make any differance in this sorting problem that I got. This post needs to be sorted before presented. This sort should be easy if it wasn't for the cases where RouteDistance is zero. RouteDistance is the priority element that this sort should be done on but in those cases where RouteDistance is zero, the fallback is to match the Distance for the RouteDistance instead (but only the one which is zero). Then the sorting continues on RouteDistance until a new RouteDistance with zero arraives and in that case, same thing, sort this in on distance instead. The XMLpost contains of a maximum of 20 hashes so there is room fore some bad performance sorting aswell. Ofcourse a fast and clean solution would be the best but as this point I'm open for any soltion that would solve this problem. As I wrote in the "uptate 1" post in the original post I can accept an solution where the RouteDistance value is modified by for example + 0.01 / - 0.01 (depending how the loop is iterating over the array) with the nearest RouteDistance. I do find my example tables informative where I first wrote the original data and then what I expect after the sort is done. If you need more information you let me know, I find this a bit hard to describe, escpecially since I'm not that good at English
In Section
Seekers of Perl Wisdom
|
|