[Tutorial] Simple sorting

Forum rules
No question in this forum please
For any question related to a topic, create a new thread in the relevant section.

[Tutorial] Simple sorting

Postby robleyd » Thu Jun 20, 2019 12:12 pm

A question appears here occasionally about sorting data in multiple columns - how to retain the relationship between columns when you only want to sort by the data in one column.

The solution is simple; you need to select all the columns, even though you only want to use the information in one column as the basis for your sort.

Let's say I have my entire music collection - all 20 or so songs - listed in a spreadsheet in no particular order. I have three columns, Artist, Song and Year. All well and good, but I want them listed in alphabetical order of artist name. So I select the entire range of song information.

Then I go to the menu at the top and select Data | Sort which provides a dialogue box to allow me to define the order in which I want the data sorted. Artist name is in column A, so I choose to sort by column A in ascending order.

I click OK and the information in column A is sorted according to my specifications, and data in the other columns retains its relationship to column A.

Ah, but although the artists are in order, I'd like to have the songs in chronological order as well, so earlier songs by the same artist are shown before later efforts. So, with the entire data selected as before, I go back to Data | Sort and this time select column A as the primary sort, and column C as secondary sort order. This will sort by artist name, and then by date for that artist.

I click OK and I have what I want.
Last edited by robleyd on Thu Jun 20, 2019 2:46 pm, edited 1 time in total.
Reason: Change subject
Apache OpenOffice 420m2(Build:9821) - Slackware 14.2 - 64 bit
LibreOffice (SlackBuild for 6.4.6 by Eric Hameleers) - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
Posts: 3636
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: [Tutorial] Simple sorting

Postby MrProgrammer » Mon Aug 05, 2019 6:33 pm

robleyd wrote:The solution is simple; you need to select all the columns
Even better, select them then use Data → Define Range and give this range a name. Under → More you will usually want ✓ Insert or delete cells and ✓ Keep formatting. Ensure that you have set Contains column labels correctly, then click OK.

After naming the range, when you select a cell in it and use Data → Sort, Calc knows you want to sort this entire range. And, when sorting at a later time, Calc will remember what sort criteria you used and have those values pre-set in the Sort dialog so you can quickly do Data → Sort → OK.
Mr. Programmer
AOO 4.1.7 Build 9800 on MacOS 10.14.6.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
Posts: 3854
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Return to Calc

Who is online

Users browsing this forum: No registered users and 1 guest