use api for YAML ordering instead of text munging

YAML provides an API for ordering nodes.  Use it instead of munging the text output.