Sorting documents in views
Most views can benefit from a sorting method that organizes documents in a way that makes sense to users. For example, a By Date view sorts documents by their creation dates, and a By Author view sorts documents by author names. To achieve this effect, designate at least one column as a sorting column. Then define it as a user-sorted column, an auto-sorted column, or both.
Views that display categories often use sorting methods to alphabetize the category names.
Ascending and descending order
Columns sort documents in ascending or descending order:
- Ascending order sorts in increasing order (where 1 precedes 2,
A precedes B, earlier dates precede later dates).
For example, to display documents from oldest to newest, create a Date column that uses the Creation Date as its value and sorts documents in Ascending order.
- Descending order sorts in decreasing order (where 2 precedes 1,
B precedes A, later dates precede earlier dates).
For example, to display documents from newest to oldest, create a Date column that uses Creation Date as its value and sorts documents in Descending order.
Character sorting rules
After the ascending or descending order is set, characters are sorted in this order:
- Numbers
- Letters
- Accented letters
- Punctuation/special characters
Case-sensitive and accent-sensitive sorting rules for Release 5 and greater differ from sorting rules in previous releases in the following ways:
- Both case-sensitive sorting and accent-sensitive sorting are turned off by default (in previous releases, they were on by default).
- "Case-sensitive sorting" sorts lowercase letters before uppercase letters -- for example, "ab" sorts before "Aa."
- "Accent-sensitive sorting" sorts accented characters after non-accented characters. For example, "ab" sorts before "äa."
Sorting multiple values
If the sort column displays values from a multiple-value list, select "Show multiple values as separate entries" to show each value as a separate row. If you don't set this option, multiple values display as one entry.
Setting this option correctly on a sorted column may still not produce the results you are expecting. In the following example, Julie has created a document with a field containing the items apples and chickens. Bill has created a document with a field containing the items bananas and ducks. When you sort the Entry column in ascending order and specify "Show multiple values as separate entries," the following view results:
To list multiple entries from a document together, you must sort a column to the left. In this example, sorting the Author column creates the following display:
And finally, to streamline the display, you can categorize the Authors column to produce the following:
Displaying a categorized view as flat
If you enable this option on a column that precedes a categorized column, this column and the subsequent categorized column are merged into a single category heading; both column values are visible on the same category row, instead of having a category for the first column, and within that a subcategory for the second column. The effect is essentially the same as if you had merged them into a single categorized column with the formula 'field1 + " " + field2', except that you can still individually set the column widths, fonts, and sort directions for the two columns. You should only display a "twistie" on the first column. It will still work if you display it elsewhere, but it might be confusing for users.
This is helpful if you have so many levels of categorization that you're exceeding the Notes® limit of 32 levels. You may also choose to do this for ease of use, when the number of combinations in two categorized columns is likely to be small, and you want to let the user navigate to the desired document with fewer clicks.
User-sorted columns
Users see a twistie next to a column title whose values can be resorted. Users click the column and choose a sorting method to see the documents in the order they choose.
To set up a user-sorted column, select the option "Click on column header to sort" on the Sorting tab of the Column Properties box. Then select Ascending or Descending order, or select Both to allow users to cycle among ascending sort order, descending sort order, and no sort order for the column.
Deferred sort index creation
Every view contains a primary "index" that remembers the sort order of the rows based on the sorted columns. For each column where you have enabled "Click on column header to sort," the server creates an additional index to remember the sort order based on that column. The primary and secondary indices are stored together, and by default they are all kept up to date, so when the user clicks a column header, the re-sorted contents are available immediately.
If you expect that a certain re-sort column will rarely be used, select the option "Defer index creation until first use" for that column. This tells Notes® to not create the secondary index for that column until a user clicks the column heading for the first time. There may be a long delay the first time, because before the re-sorted view can be displayed, this "on-demand" index must be created from scratch. If it never happens, though, server performance is increased by avoiding unnecessary indexing.
Once a secondary index has been created, it will be automatically refreshed along with the primary index. If users continue to use the re-sort, it will have good performance. However, if the on-demand index is unused for the discard interval specified in the view properties, that index will be discarded, even if the primary index is still in daily use. You can also explicitly remove all on-demand indexes in an application by using this command from the server console: load updall <dbname> -r -g.
Associate the sort index creation with the column, because you might want to have some of your re-sorts on-demand and others not, in the same view.
Auto-sorted columns
To set up automatic sorting, select the option "Sort: Ascending" or "Sort: Descending" on the Sorting tab of the Column Properties box. The sorting column is usually one that appears on the left side of the view.
Multiple sorting columns
To create multiple levels of sorting, designate more than one column as a sorting column. For example, if a primary sorting column sorts entries by date, a secondary sorting column might sort entries by author. Then all documents created by one person on a particular date are grouped together.
Using an auto-sorted column as the secondary sorting column
To add a secondary sorting column, add a column following the first sorting column and then choose Sort: Ascending or Sort: Descending on the Sorting tab of the Column Properties box. Documents and responses are sorted, then sub-sorted, in column order from first to last.
Designating a secondary sorting column for a user-sorted column
User-sorted columns override the sorting built into auto-sorted primary and secondary columns. If the view has a user-sorted column and you want to include secondary sorting, you can associate it with a secondary sorting column. On the Sorting tab of the Column Properties box for a user-sorted column, click "Secondary sort column" and choose the secondary sort column and its sorting order.