List manipulation idea


#1

I’m wondering if anyone has attempted the following: Let’s say you have a draft that is a list (using the handy-dandy [x] boxes) and some of the items on the list have been checked off. Is there a method using scripting to reorder the lines in the draft so that all the checked lines move to the bottom and the unchecked lines move to the top of the list?
I have only rudimentary scripting skill and don’t even know where to begin, but it might be worth the time for someone who knows what they’re doing.

Thoughts?


#2

That’s definitely do-able via scripts. In fact, I’d suggest it’s a great first project if you’re looking to learn.

I’d start with the pseudo code. Something like:

// break draft into lines
// sort lines based on their leading characters
// recompile draft

#3

That look like a logical breakdown. I’d also like to make sure that the first line stays the same (as a title) and the moved lines retain their original order relative to each other.

Looks like I’ve got some learnin’ to do! Hopefully I’ll have it done before Drafts 6 :wink:

thx


#4

Would you want the order of items maintained, or does it not matter? I may have some ideas :slight_smile:


#5

Ideally, I would like to keep the lines in the same relative order. But I’m definitely open to all input. Thx.


#6

I have this completed already. If you can wait a week, it will be in an action group that is in the review I’m writing. :grin:


#7

A simple alphabetical sort would actually put the completed at the bottom whilst keeping unchecked at the top - and it would alphabetise all of the tasks between. As @nahumck has a solution already that likely preserves order I’ll leave that to him!


#8

Wow! You are a shining example of the true spirit of the Drafts community!

And no, I can’t wait :wink:


#9

It keeps the same order in which you check them off. I’m sure it can be modified as needed once it’s out there.