Move nodes sorted to helpers, and use it in parser.node.list_nodes too