toml icon indicating copy to clipboard operation
toml copied to clipboard

Function for inserting table key at ordinal in a `TableLike`

Open nathaniel-daniel opened this issue 7 months ago • 1 comments

Hello, I would like a function that would allow me to insert a key at a specified ordinal in a TableLike. I have a program that accepts a config file like the following (example):

[user]
first = "John"
last = "Doe"

Then my program will generate a key which is considered more "important" than the others, and I would like to place it at the top like so:

[user]
id = "John-Doe-1234"
first = "John"
last = "Doe"

However, there doesn't seem to be an api to control the insertion order of keys in a TableLike. Furthermore, a TableLike doesn't have a sort_values_by method. Combined, I don't believe there is a way to control entry order in a TableLike at all. Would it be possible to add some functionality to give users more control over entry order in a TableLike, or provide some control over the insertion location?

nathaniel-daniel avatar Jul 04 '24 03:07 nathaniel-daniel