Added Sort function for selection of nodes