Split content and Lists

I am importing the text separated using split by new line
I need 2 parts for the snippet, top part will only list text to the left of the - sign
The bottom part will outputthe string to the left of the - sign and then the whole text in detailed explanation. But the order when using for i starts at 2 not at 1 and pairs the heading with the text for the next heading.

Something wrong in my for i loop but I cannot figure it out,

First part is the snippet I use, second the imported snippet

{headings=sort(map(split({import:!test01}, "\n"), item -> split(item, " - ")[1]), (a, b) -> comparestrings(a, b))}{content=split({import: !test01}, "\n")}{explanation1=[split(content[i], " - ") for i in seq(1, count(content))]}
{listoflists=[headings[i]:explanation1 for i in seq(1, count(content))]}{formmenu: values={=headings}; name=chosenheading; multiple=yes}
{note}{explanations=[split(content[i], " - ")[1] for i in seq(1, count(content))]}
{listoflists=[headings[i]:explanations[i] for i in seq(1, count(content))]}
{formmenu: values={=headings}; name=chosenheading; multiple=yes}
{=join([concat(choice, ": ", listoflists[choice]) for choice in chosenheading], "\n")}{endnote}

option1 - for option 1 long explanation blah, blahm blah
option 2 a bit longer title - for option 2 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec malesuada eu eros ut porta. Sed id viverra odio, ac vulputate ligula. Phasellus convallis augue eu turpis lobortis pulvinar. Nunc in egestas lacus, ut mollis augue. Morbi malesuada feugiat rhoncus. Nam cursus lacus in ipsum hendrerit vehicula.
option 3 - for option 3 Integer faucibus efficitur urna, commodo scelerisque arcu aliquet sed. Quisque porta, libero eu iaculis tristique, mi purus hendrerit massa, dictum sodales risus lacus non est. Ut pulvinar, libero at ultrices rhoncus, felis sem facilisis tellus, suscipit scelerisque diam dui et odio.

@Cedric_Debono2 @Cedric_Debono_Blaze @cedricdebono @Cedric_Debono1 @Cedric_Debono

Hi,

I'm not sure I understand what you are trying to achieve. Can you post the output you are looking for?

First off, I do not see the options in the expected order

Expected to have option 1 listed at top

Both the note and the headings in the upper part of the snippet are going to option 2 first.
How can I get the order correct? So option 1 matheading is mathed w option 1 explanation?
image

I would like to split the above so I can use the string left of "-" as heading and the part of the string to the right of "-" as the explanation.
The heading is the bit which will be inserted into the actual snippet.
The heading plus explanation will be the part which will be shown in a note as a reminder what needs to be done per heading selected.

When I select option 1 I expect to see the explanation for option 1 listed next to it in the note.

Thank you for the reply.

Hi,

The issue with sorting is you have "option1" and "option 2" (note the spacing difference). The space character is sorted before the "1".

If you use consistent spacing across your options, they will sort correctly.

Does that help?

Oh dear.
THANK YOU
That did fix everything indeed.

Glad it's fixed!

@scott
One more thing please

I am getting output Heading: heading
I would need Heading: explanation. (in the note)

How can I achieve this?

!test02
image

I would like to have:

option 1 - for option 1 long explanation blah, blahm blah
option 2 a bit longer title - for option 2 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec malesuada eu eros ut porta. Sed id viverra odio, ac vulputate ligula. Phasellus convallis augue eu turpis lobortis pulvinar. Nunc in egestas lacus, ut mollis augue. Morbi malesuada feugiat rhoncus. Nam cursus lacus in ipsum hendrerit vehicula.
option 3 - for option 3 Integer faucibus efficitur urna, commodo scelerisque arcu aliquet sed. Quisque porta, libero eu iaculis tristique, mi purus hendrerit massa, dictum sodales risus lacus non est. Ut pulvinar, libero at ultrices rhoncus, felis sem facilisis tellus, suscipit scelerisque diam dui et odio.

You have your explanations set to:

[split(content[i], " - ")[1] for i in seq(1, count(content))]

They should probably be set to instead:

[split(content[i], " - ")[2] for i in seq(1, count(content))]

Thanks Scott,