Sorting data in OpenOffice.org Calc (repost)
You want to do some good, hard sorting. Not just sorting by the first column, but by perhaps the third column. Maybe you want to sort first by state, then by city, then by last name. For that, you need the Sort window under Data > Sort.
You have your data. Select all the data to sort, and either select the headings or not. You're good either way.
Choose Data > Sort.
Click the Options tab. You need to tell Calc whether you've got headings selected or not. If you've got headings selected, you want the option shown, "Range Contains Column Labels," to be selected. If you didn't, unmark it.
Now click the Sort Criteria tab. If you selected headings you'll see the headings themselves; if you didn't then you'll just see Column A, etc. Select the column to sort by, and Ascending or Descending.
Click OK.
You get your results. Here, the amounts under the column for the year 2000 are sorted in ascending order.
Now, let's look at a different set of data. You have a lot of people from the same state, and several cities per state. In this case you might want to just sort by last name, but you could also group by location. So you'd sort by state (the broadest category), then city, then alphabetically by last name. Click the image to see more detail.
Select the data, with or without headings, and choose Data > Sort. In the Options tab, be sure to select the Range Contains Column Labels option if you selected headings.
In the Sort Criteria tab, select first State, then City, then Last Name.
Click OK.
You get your results. Here's a closeup of one section, followed by the complete data. Click either to see them closeup.
This window that I've covered in this blog entry is pretty much what you need. If you want to go a little farther and sort by something else, like days of the week in the order they come, not alphabetical order, tune in for the next sorting blog.



































































Thanks to Huw for the tips. For information on the sites, see:
http://www.openoffice.org/issues/show_bug.cgi?id=33851
http://wiki.services.openoffice.org/wiki/Calc/Drafts/Issue_33851
http://wiki.services.openoffice.org/wiki/Talk:Calc/Drafts/Issue_33851
Let's say you've got a big list of employees: name, address, etc. When you apply the filter and view, for instance, only people from Montana, some of the data isn’t shown. If you then copy, paste, delete, or perform other operations on the data, what happens to the data that isn’t shown? If you delete Artie Anderson from Montana and Cindy Chalmers from Montana, what happens to Betsy Bates from Nevada?
It all depends on the operation. Some, like delete, leave the unshown data alone. Some do affect the unshown data.
Operations that DO affect filtered out rows.
Cut and Paste
Move (dragging)
Fille (Edit > Fill or dragging)
Operations which do NOT affect filtered out rows:
Copy
Delete contents
Delete row
Format
Find & Replace in current selection
More About Operations that DO Affect Filtered-Out Rows
Cut and Paste, Versus Copy and Paste
With Cut and Paste, the non-shown data is cut and also pasted.
Click the following to see a bigger image.When you paste the data outside of the filter range, the whole set of data is pasted and unaffected anymore by the filter.
When you paste the data inside the filter range, the whole set of data is pasted, and all data is shown at first, even data that shouldn’t show for the current filter selections. However, if you re-apply the filter selections using the dropdown lists in the heading row, then the data is filtered correctly.
With Copy and Paste, the behavior is different. If you cut, you get the nonshown rows, but if you copy, you don’t.
Dragging Cells to Move Them
When you move rows (dragging) that include unshown rows, the behavior is the same as cut and paste. The unshown rows between shown rows are moved along with the shown rows.
Fill (Edit > Fill or Dragging the Cell Handle)
Here’s what happens with Fill. Here’s some sample data, and currently everyone is in the same department.
You now look at only people from Colorado.
You change the department for the first person from Colorado, and drag that department down through all the other people from Colorado.
Now, all the nonshown rows after the first row you changed are affected, but not the rows before that.
More About Operations that Don’t Affect Filtered-Out Rows
Copying and pasting, deleting, formatting, and Find and Replace don’t affect unshown data. The following section provides an example.
Deleting
Here’s a walkthrough of deleting rows while the filter is on. Rows that aren’t shown aren’t affected.
Look at the range from row 15, Dan Montbatten, to row 20, Beth Jerlin. Dan and Beth are both from Montana. In between are Jon, Marcus, and Kyle.
The next illustration shows an AutoFilter with only people from Montana, which includes Dan and Beth but excludes the three rows between.
Now delete Dan and Beth.
And they go away. However, when the state autofilter criterion is removed, Jon, Marcus, and Kyle are still there.