Sort drag and drop

Hi,

i was was wondering , is there a way to sort a dragable list using the “list tagged draggable macro” and retain the sort order whilst keeping the drag and drop working

so in this example https://tiddlywiki.com/#TaskManagementExample%20(Draggable)

you start with this order

1-Make the beds
2-Get the Ring
3-Kill the Dragon
4-Compose ballad

if i add a sort[]


the order becomes

1-Compose ballad
2-Get the Ring
3-Kill the Dragon
4-Make the beds

but offcourse the list is no longer draggable as the sort[] will enforce the list to snap in alphabetical order

so now i remove the sort[] , but then the order switches back to the orignal ordering without the sort

is there a way to retain that alphabetical ordering ?

i want to have a button , to sort the entries , but still allows to move things around if i want to, so its like a one time sort thing, not a persistent sort

hope this makes sense

thank you

You need to save the resulting list back to the field to make it permanet but consider if you need to, you can always sort it again.

1 Like

Thanks tones,

sorry save it to which field?

After drag & drop sorting the tag-tiddler should have a list field, that contains the sort order.
It will be updated by the d&d operation
-m

1 Like

Thank you found it :slight_smile:

sorry to come , back , but apparently the List field only stores the list order, modifying the field does not change the list order , like its a one way realtionship

my idea was to store the order after the sorting i like ,then set the field to that order after removing the sort

is their another way of controlling the order of a drag&drop list?

Edit : ok i take that back sorry :frowning: it does , the problem is that sorting the drag&drop list does not reflect in the tagged tiddlers list field , hence any sorting i am doing is useless becuase i cant store/recall it

and so i guess i am back to my original question , is there a way to sort a Drag&drop list ?

It’s a bit tricky. Let’s say we have 3 tiddlers tagged: a – The code may look like this:

The important function is “format:titlelist” – If you search for “titlelist” here in the group you may find more interesting threads about titlelists

\procedure sortTag()
<$action-setfield 
  $tiddler=<<tag>>
  $field=list
  $value={{{ [tag<tag>enlist-input[]sort[]format:titlelist[]join[ ]] }}}
/>
\end

\procedure sortByTag(tag)
  <$button actions=<<sortTag>>>Sort</$button>
\end 

<<sortByTag a>>

<<list-tagged-draggable tag:"a">>

sortByTag-macro.json (3.8 KB)

have fun!
mario

thank you ,

I got it now , thank you for your help