sort values before assgining to nodes