Sort Everything by Anything
New Sort MacrosAlong with this update there are six new macros are available that can be readily used and demonstrate the feature:
- Sort Pages: Sort pages in current section by name, preserves page/subpage hierarchy
- Sort Pages by Date: Sort pages in current section by created or last modified date, ascending or descending
- Sort Sections: Sort sections in current Notebook by name
- Sort Notebooks: Sort open notebooks by name
- Sort Paragraphs: Sort selected paragraphs or list items alphabetically or numerically, preserves list hierarchy
- Sort Table: Sort selected column or the whole table alphabetically or numerically, ascending or descending
Note that if you sort pages, sections or notebooks, you cannot undo this.
How Sort Command WorksSince this now becomes part of macros, you can extend these or write new ones to sort anything you want by any property or value you decide. A simple sort macro looks like this:
You can filter the items to be sorted by using That and Under clauses as you can do so in For loops. Following will sort each paragraph under a Table that has more than 2 rows and is edited by "John":
Custom Sort OrdersYou can see how powerful this is as it has full access to every property. You can also define custom sort orders by making use of variables. Below macro will sort each paragraph by the second letter that appears in the paragraph:
The variable to be used in sort must be an array that has indices 0 to number of elements being sorted.