Skip to content

[feature request] Ordered mapping keys #52

@agladysh

Description

@agladysh

I would like to order mapping keys in the dump for human readability.

For my use case a flat list is enough.

How about something like this?

yaml.dump(data, { mapping_key_order = { "key1", "key2", ... } }) -- keys not in the list are dumped in the end

and, for finer control:

yaml.dump(data, { mapping_key_order = function(mapping) -- This may be the default if mapping_key_order = true
   local keys = tkeys(mapping)
   table.sort(keys)
   return keys
end }) -- keys not in the list are dumped in the end

If mapping_key_order is not specified, use the current implementation for performance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions