Sams Teach Yourself StarOffice® 5 for Linux in 24 Hours |
![]() |
|||||||||||||
Hour 18: Using Database Functions |
![]() |
|||||||||||||
|
Another of the truly useful database features in StarOffice is the capability to sort lines of information.
You can choose which field to sort on, and set other sorting options to fit your data arrangement.
The same sample list of names and addresses is used to show how sorting works.
The first step in sorting data is selecting the area that you want to sort. This area consists of a block of cells, including the field names at the top of the block. Figure 18.8 shows the selected cells that you want to sort.
Remember these two dangers as you select the area to be sorted:
If you don't select all the rows in the table, they are left at the bottom of the table, unsorted. This problem can be solved by selecting the entire table and resorting.
If you don't select all the columns in the table, the sort operation rearranges the first part of each row, leaving the mismatched last part of each row (record). You can fix this by choosing Undo from the Edit menu if you recognize the problem immediately.
After you have selected the cells to be sorted, choose Sort... from the Data menu. The Sort dialog box appears (see Figure 18.9).
Figure
18.8
The
full table, with field names, is selected for the sort operation.
Figure
18.9
The
Sort dialog box enables you to choose options for how a block of records is
sorted.
The method used to sort a list of records in StarOffice is based on two things:
Which column is to be sorted (used as the key to the sort)
Are the highest values or the lowest values listed first
The first field in the Sort dialog box is Sort by. Click on the drop-down list and notice that it contains the names of the fields from your sample data. It's a good idea to include the field names in the block of cells that you select for sorting.
Tip - The field that you sort on is sometimes called the sorting KEY. |
Suppose that you want the list sorted by state, and then alphabetically within each state. Follow these steps:
1. From the Sort by drop-down list, select State. (If you're using different sample data, the items in the list are different.)
2. Choose the Ascending button (so that AL is listed first and WY last).
3. Now that the first Sort by field is defined, you can select a second field from the next field down, labeled Then by. Choose Name from this drop-down list.
4. Also choose the Ascending button next to this field (so that Allan is listed first and Zoe last).
With the sort criteria set, you can choose OK, and the records are sorted.
Sorting in StarOffice provides many other options, however, in addition to setting up the sort criteria.
Select a block of cells and choose Sort from the Data menu. Then choose the Options tab (see Figure 18.10).
The following sections describe each of the items in the Options tab:
When the Case sensitive checkbox is selected, all alphabetic sorting is based on upper- or lowercase letters, instead of all letters being treated the same.
When the Area contains column headers checkbox is selected, the Sort criteria window uses the words in the first row to help you identify which sorting method you want to use.
Figure
18.10
The Sort dialog box includes an Options tab in which you can set up many variations
in how StarOffice sorts records in your tables.
Note - You can uncheck this box and choose the Sort Criteria tab to see that the drop-down list contents change to Column B, Column C, and so on. |
When the Include formats checkbox is selected, the format of each cell is moved with it during the sorting process. If this checkbox is not selected, the values are moved, but the formatting remains as it was before the sort.
For example, some lines might be highlighted in bold. The bold format can follow the sorted line, or remain on the same row as new data is sorted into that position.
The Copy sort results to checkbox indicates that the sorted table is to be copied to another location in the spreadsheet, rather than replacing the selected cells that are being sorted.
The drop-down list shows any names that you have defined within your spreadsheet (defining names was described in Hour 14, "Entering Spreadsheet Data").
If you don't have names defined, or prefer to use another area of your spreadsheet, you can enter cell references in the text entry field to the right of the drop-down list below the Copy results checkbox.
The Custom sort order checkbox enables you to define an ordered list that is used to sort information, rather than the alphabet or numerical sequence.
Some ordered lists are already defined in StarOffice, such as days of the week and months of the year.
Finally, you can change the sorting so that one column is considered a record and each row is a field. Instead of rearranging the rows, a sort rearranges the columns from left to right.
Sams Teach Yourself StarOffice® 5 for Linux in 24 Hours |
![]() |
|||||||||||||
Hour 18: Using Database Functions |
![]() |
|||||||||||||
|
© Copyright Macmillan USA. All rights reserved.