in reply to Re^6: Sorting an array of hashes with an exeption
in thread Sorting an array of hashes with an exception

That is what my code does. It sorts by RouteDistance, but in case it is zero, it is replaced with Distance. Your example, though, uses Distance even if the RouteDistance is zero on the other element being compared to. This is generally not possible, consider:
ID => 1, Distance => 10, RouteDistance => 1, ID => 2, Distance => 9, RouteDistance => 0, ID => 3, Distance => 8, RouteDistance => 2,

According to your logic, ID1 < ID3 (1<2), but ID3 < ID2 (8<9) and ID2 < ID1 (9<10), therefore ID3 < ID1. Your order is not transitive.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^8: Sorting an array of hashes with an exeption
by martin_87 (Initiate) on May 10, 2013 at 17:47 UTC

    But I don't want to replace RouteDistance with the value of Distance. I want to sort it by Distance (match with the other Distance values that the hashes got) in cases where RouteDistance is zero.

    Anyhow, the problem is now solved.

    Thanks for helping out, Choroba.