In my database, I have two variables "longitude" and "latitude". I use a function to know the distance between the user and the element in my database, for instance a touristic site.

The problem is to order results knowing that my distance variable ($longueur) is defined in my while loop for each result so i can't use a ORDER BY

Thanks in advance for your tips

PHP Code:
="SELECT * FROM matable WHERE Statut>='0'";
get_distance_m($Lat$Long$user_Lat$user_Long) {...}
$longueur=round(get_distance_m($Lat$Long$user_Lat$user_Long) / 10003);
... HTML Code ...