Sort nodes on name if set, otherwise ID (fixes #119)