Importing and Sorting

I have a large file of Text/Markdown notes (about 700) which I want to important into an existing TBX file. I also want to sort them on $Name as I add them. I am experiencing two problems. 1) I drag and drop 10 at a time and I save after each drop. At some point (around 300), TBX simply hangs. It appears to be caught in a loop. 2)What is more the sort function behaves strangely. It will sort properly a batch of 30 or so up to “D”, then suddenly throw in a few “Bs” after which it will proceed to work as it should. Please advise as to proper procedure to batch import of txt/md files and to the investigation of sort irregularities.

You’ll be far better advised to import the notes, and then sort them.

This is really a matter of mathematics. If you have N things to sort, the best sorting algorithm possible requires about N log(N) operations. OK: that’s just the best you can do.

If you import 10, then sort, you wind up doing a LOT more work. For example, the next-to-last step requires ~690 log(690) operations, which is nearly as much as the final sort.

What’s worse, if you sort, and then you add things, you might wind up sorting while you’re adding the new things. It’s a push-me-pull-you situation. It should eventually get sorted out (!), but it’s not great.

Just import the batch, save, and then set the sorting.


Thank you Mark

Another wrinkle here. With large containers (100s of items), once sorted consider if you need to leave the sort on. It’s enlightened self-interest. You’re re-sorting, constantly, sorted material that won’t change. Adding some more content later? It’s easy to sort then turn sorting off. Admittedly, it’s even easier to turn it on and leave it on, but that might not be helpful once the volume of notes things grow (for reasons already given above).

How to do this? The easiest UI way is to open the Sort Inspector. In the search box type the name of the desired attribute on which to sort, e.g. Name, and hit enter—or accept a name from the autocomplete list. The container will sort. If you think it isn’t, click the view’s tab (at the top) and this will force a view refresh. Once sorted, in the Inspector search for don't sort and select it: the automatic sorting is turned off although all the notes remain as per the last sort. In other words, turning sorting off doesn’t cause that notes to resume some prior sort order.