sort nodes in findnearest nodes function