Sort Everything by Anything

May 25, 2014

An update for Onetastic is available that adds ability to sort everything you can in OneNote by any property you want. This is added as a new Sort command in macros.

New Sort Macros

Along with this update there are six new macros are available that can be readily used and demonstrate the feature: Sort macros

Note that if you sort pages, sections or notebooks, you cannot undo this.

How Sort Command Works

Since 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: Simple sort macro

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": Sort filters

Custom Sort Orders

You 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: Custom sort orders

The variable to be used in sort must be an array that has indices 0 to number of elements being sorted.

Sorting Objects that aren't Siblings

When sorting objects that are not under the same parent object, they are sorted only within their siblings. For instance if you try to sort all pages in current notebook, they will be sorted within each section and they won't move between sections. Similarly if you sort paragraphs in a page, paragraphs in same outline will be sorted together but not across outlines. This is the desired behavior for most cases and will prevent simple mistakes to mix everything up on your pages or notebooks.

Other Feature Requests

Ability to sort was the most requested feature for Onetastic and is the first new feature since I made the feature request list and asked users to vote on them. Since then new feature requests were added to the list, so don't forget to visit the feature requests page and vote on other feature requests. If you previously voted for sort feature, you will get some of those voting credits back to use on other feature requests.


Omer Atay - 2020-12-01
RobertC: OneNote unfortunately doesn't expose Title property to add-ins.
RobertC - 2020-11-28
it appears there isnt a Title property for Images.
In OneNote, right click on Image, choose altText.
Dialog box presents Title and Description.
Description = altText, however, I didnt see Title listed as a property
My image sort by alt text problem: This runs, but doesnt sort
$Images = QueryObjects("Images",GetCurrentPage())
it was when I chekced the debugger I did not find Title.
RobertC - 2020-11-27
Another Attempt:
ForEach ($Image in QueryObjects("Image", GetCurrentPage()))
   If ($Image.selection += "none")
       Array_PushBack($sort_ojbects, QueryObjects("altText", $Image))
   SortObjects($sort_objects, "altText",true)

Error about unknown object type  "altText"

Other Posts

Show all posts