Sort paragraphs
This advanced feature sorts/alphabetises any paragraphs in a Google Doc, whether or not they are part of a table.
What is special about it is that it preserves document structure.
It also handles lists and nested lists to ANY level, and recognises paragraphs that start with numbers.
When applied to tables, it will sort the paragraphs within each table cell.
All this is explained below, but if you are too busy to read it all, don't worry. It should just work!
Method for sorting paragraphs:
Drag to select the paragraphs you want to sort.
(If the paragraphs all have spaces after them, like the example, select a space AFTER the last paragraph too. Then if it changes position the formatting will be consistent.)Choose from sort options provided. (These are illustrated below.)
The small preview window makes the function of the sort options clearer.Click OK.
Feature #1: Spaces after paragraphs and numbers
Simple alphabetical sort routines are useful and often do just what we want. But they have their limitations.
For example, if the paragraphs are followed by empty lines or start with numbers the result may be undesirable:
The TableMate paragraph sorting feature solves this problem.
Numbers are sorted properly, and spaces after paragraphs are preserved:
Feature #2: Sorting lists and nested lists
Usually, lists are meant to stay with the paragraph above them.
A simple alphabetical sort destroys this structure and will just mess things up...
TableMate handles lists and nested lists properly.
Lists always stay with the paragraph above them, and nested lists stay in place:
Feature #3: Sorting paragraphs in table cells
Simply select the table cells that contain paragraphs to sort. TableMate will move to each selected cell in turn, sorting the paragraphs in each cell individually. (See example below)
Now the two selected cells are sorted:
(The other cells are not affected.)
Some technical stuff...
(Only if you are interested! But it may help you get more out of this paragraph sorting feature)
- "Sortable Text Units" (STU's)
A TableMate paragraph sort begins by scanning every paragraph selected, from top to bottom. It searches each paragraph for any letters of the alphabet, or any numerical digits.
If it finds either of these in a paragraph, that is the start of a group of paragraphs called a sortable text unit, or STU. When sorting happens, this group is kept intact.
Following paragraphs are scanned, and if they have no digits or letters they simply add to the previous STU. So empty lines, or lines of dots, tables, inline images etc, will simply add to the STU and be all moved together when sorted.
Lists are also grouped with the non-sortable paragraphs, and are sorted separately to ordinary paragraphs. (See explanation below.)
The example below is a simple example of how STU's are mapped out:
HINT: If following paragraphs contain words but must stay together, then use line breaks to start each new paragraph.
Enter line breaks in a Google doc using 'Shift+ENTER'.
In the example below, following paragraphs in each verse of the song are separated with line breaks. When sorted, they stay together...
2. Sorting of lists and nested lists
Lists are always grouped with their parent paragraph for sorting, as shown below:
The lists themselves are not sorted unless the list sorting options are selected.
Lists that are not inside other lists are called 'top level' lists. To sort top level lists, choose the 'Sort top level lists' option.
Lists inside other lists are called 'nested' lists. To also sort these, select 'Also sort lists within lists'.
Nested lists can have lists inside them, and so on. The nested list sort feature is able to handle any level of nesting!
2. How numbers and text are sorted...
When TableMate searches a paragraph from left to right, it looks for two things: (1) letters of the alphabet, and (2) numbers.
Paragraphs could have: (a) only letters, (b) only numbers, or (c) both letters and numbers.
TableMate notes the exact position where each of these start, and the sorting method depends on where the first number and/or alphabetical letter are found.
Other characters that are not numbers or letters of the alphabet are ignored.
This diagram shows what is stored for sorting for several different cases:
From the diagram above, notice that:
Leading non-alphabet/number characters, like '$' are ignored.
Text is ALWAYS recorded, even if only a number is present. This allows mixtures of pure text and numbered paragraphs to be sorted.
*NOTE: I have included leading numbers as part of the text. This way, numbered paragraphs will separate from non-numbered paragraphs in sorting.If ANY text, (eg 'USD') comes before the first number, then the number will not be used at all for sorting. Only the text will be used.
Also, if two paragraphs start with the same number, then the text will be used to decide the sort order.
NOTE: Numbers can be written in scientific notation as well, using 'E' or 'e', as in: '1.602E-19kg' etc.