Sorf collection item list by custom code

hi there

is it possible to sort acolection list by custom code? i have a script where i calculate the distance from you current location to the location of one of our partners. the distance is showed on the page but i now want to sort the list so the partner that is most closed to you is first in the list.