Weedpacket wrote:You could use [man]usort[/man] and write a function that compares the 'dist' part of two arrays.
Great! That works smooth except one thing ...it's sorting based on string value and not a numerical value so I'm getting:
22
23.4
31
40.4
8.1
instead of:
8.1
22
23.4
31
40.4
How do I fix this? I tried plugging in floatval() like this:
function cmp_dist($a, $b)
{
return strcmp(floatval($a["dist"]), floatval($b["dist"]));
}
But that didn't work. Any ideas?
Thanks!