I have a bunch of tiddlers with a "sort_order" numerical field, so that when I list them, I can sort them in a custom way using nsort.
I then have two buttons next to each one to increment/decrement the sort order, which changes the list dynamically.
Is there any way to make a button which would increment one field, while decrementing the same field in the adjacent tiddler, which would have the effect of swapping the sort order of those two tiddlers?
So I have these tiddlers:
A (sort_order=1) [up] [down]
B (sort_order=2) [up] [down]
C (sort_order=3) [up] [down]
I click the [up] button on B, which decrements the sort_order for B and increments it for the tiddler with the "target" sort order value.
B is 2.
B wants to be 1.
A is 1.
Set A to 2.
Set B to 1.
This results in:
B (sort_order=1) [up] [down]
A (sort_order=2) [up] [down]
C (sort_order=3) [up] [down]
Clicking [down] on A incremembts the sort_order for A and decrements it for the tiddler with the "target" sort order value.
A is 2.
A wants to be 3.
C is 3.
Set C to 2.
Set A to 3.
Problems:
1. How to find the "adjacent" tiddler?
2. How to refer to the same field in the adjacent tiddler?
3. How to set the same field in both the current and adjacent tiddlers, one incremented, the other decremented (or vice-versa)
I'm just brainstorming here, but a list with a changeable sort order would be very useful.