Information Technology Topic
Sorting a Spreadsheet
- Read notes
- Flashcards
- Quiz
- Confident
Study focus - 3 things
- Sorting rearranges whole rows (records) into order: ascending means A to Z or smallest to largest, descending means Z to A or largest to smallest
- The primary field decides the main order and the secondary field only settles ties between records that have the same primary value
- Read the wording to choose the settings: highest first means descending, alphabetical means ascending, and the headers option keeps the column titles out of the sort
Section 1Sorting: putting records in order
A table in a spreadsheet is a list of records. Each row is one record (one student, one product, one runner) and each column is a field (surname, class, mark). Sorting rearranges the rows into an order you choose, using the values in one or more fields. A class list goes into alphabetical order. A results list puts the highest mark at the top. The contents of the cells do not change. Only the position of each row does. Here's the trick: whole rows move together, so every record stays in one piece. Brown's class and mark must travel with Brown's surname.
Section 2Ascending and descending
Ascending order runs from A to Z for text and from 0 to 9 (smallest to largest) for numbers. Descending order is the opposite: Z to A, and 9 to 0 (largest to smallest). For example, the marks 75, 40, 90 and 62 in ascending order are 40, 62, 75, 90. In descending order they are 90, 75, 62, 40. The surnames Reid, Allen, Thomas and Clarke in ascending order are Allen, Clarke, Reid, Thomas. Choose the direction by what you want at the top. A top-scorers list needs the marks descending. A race result needs the times ascending, because the smallest time belongs to the winner. When every value is different, descending order is exactly the reverse of ascending order.
Section 3Primary and secondary fields
Often a field has repeats. In a Form 4 mark sheet in Portmore, three students may all score 72. Sorting on Mark alone does not say which of the three comes first. So you can set more than one sort field, and the sheet applies them in turn. The primary field is applied first and decides the main order. The secondary field is used only to break ties: it puts the records that share a primary value into order among themselves. Easy to mix up: the secondary field never overrides the primary one. A record with a higher mark stays above a record with a lower mark, whatever their surnames are. Each field has its own direction. A common pair is primary Mark descending with secondary Surname ascending: best mark first, and students on the same mark in alphabetical order.
Section 4The steps to sort
1. Select all the cells of the table, every column, so that the rows move as whole records. 2. Open the sort tool. 3. Tell it whether the first row holds column titles. The headers option leaves that row out of the sort, so the titles stay at the top. 4. Choose the column for the primary field and choose ascending or descending. 5. Add a secondary field, with its own direction, if ties need settling. 6. Confirm, then look at the result. The quick sort buttons sort one column, ascending or descending, in a single step. They are fine for one field. For a primary and a secondary field, use the sort tool. Adding a new record at the bottom and sorting again beats hunting for its right place by hand.
Section 5Tracing a sort with ties
Take this mark sheet (surname, class, mark): Brown 4B 72, Campbell 4A 85, Reid 4B 85, Clarke 4A 64, Gordon 4C 72, Davis 4A 91, Thomas 4C 58, Francis 4B 64, Allen 4C 85, Morgan 4A 72. Primary Mark descending, secondary Surname ascending. Group by mark first: 91 Davis; 85 Allen, Campbell, Reid; 72 Brown, Gordon, Morgan; 64 Clarke, Francis; 58 Thomas. Inside each group, order the surnames A to Z. The result is Davis, Allen, Campbell, Reid, Brown, Gordon, Morgan, Clarke, Francis, Thomas. Primary Class ascending, secondary Mark descending gives class 4A first (Davis 91, Campbell 85, Morgan 72, Clarke 64), then 4B (Reid 85, Brown 72, Francis 64), then 4C (Allen 85, Gordon 72, Thomas 58). Watch out: change the order of the two fields and you get a different list. Class then Mark is not the same as Mark then Class.
Section 6Choosing the sort for the job
Match the wording of the job to the settings. Alphabetical list of students: Surname, ascending. Merit list, highest first, same marks in alphabetical order: primary Mark descending, secondary Surname ascending. Class lists with the best mark first in each class: primary Class ascending, secondary Mark descending. Race results with the winner on top: Time ascending. A field in which no two records are the same, such as a staff ID, never ties, so a secondary field adds nothing. A field like Class or Mark has repeats, so a secondary field is useful.
Section 7Common slips and how to check
Watch out for three slips. If you select only one column, that column is sorted but the others stay where they were, so marks end up beside the wrong names. Some programs offer to widen the selection, but do not rely on it. If the headers option is off, the heading row is treated as a record and can be sorted down into the data. If you pick descending when the job says lowest first, the list comes out upside down. After sorting, check three things. The first and last rows are the ones you expect. The number of records is the same as before. Each surname still has its own class and mark. And read down the sort field. Each value should be the same as, or after, the value above it.
Examples
At a Kingston school sports day, the 100 m times in seconds are stored in a table with the headings Athlete and Time: Reid 12.8, Grant 12.5, Lewis 13.1, Bailey 12.6, Mills 12.9. The teacher sorts the table by Time with the headers option on. (a) Write the order of the athletes from top to bottom for an ascending sort. (b) Write the order for a descending sort. (c) State which sort puts the winner directly under the heading row, and explain why.
(a) Ascending means smallest to largest. The times in order are 12.5, 12.6, 12.8, 12.9, 13.1. So the athletes are Grant, Bailey, Reid, Mills, Lewis. (b) Descending means largest to smallest, so the list is reversed: Lewis, Mills, Reid, Bailey, Grant. Every time is different, so descending is the exact reverse of ascending. (c) The ascending sort. In a race the smallest time wins, so Grant (12.5) should be first. With the headers option on, the heading row stays at the top and Grant sits directly under it.
A Form 4 teacher in Portmore keeps this mark sheet (surname, class, mark): Brown 4B 72, Campbell 4A 85, Reid 4B 85, Clarke 4A 64, Gordon 4C 72, Davis 4A 91, Thomas 4C 58, Francis 4B 64, Allen 4C 85, Morgan 4A 72. (a) The sheet is sorted with primary field Mark descending and secondary field Surname ascending. List the surnames from top to bottom. (b) Explain why Allen is above Campbell and Campbell is above Reid. (c) The sheet is now sorted with primary field Class ascending and secondary field Mark descending. List the 4A records from top to bottom.
(a) Sort by mark, highest first, then settle ties A to Z. 91: Davis. 85: Allen, Campbell, Reid. 72: Brown, Gordon, Morgan. 64: Clarke, Francis. 58: Thomas. The order is Davis, Allen, Campbell, Reid, Brown, Gordon, Morgan, Clarke, Francis, Thomas. (b) Allen, Campbell and Reid all scored 85, so they tie on the primary field. The secondary field, Surname ascending, puts them in A to Z order: Allen, Campbell, Reid. (c) Class 4A comes first because 4A is the first class in ascending order. Inside 4A the secondary field puts the highest mark first: Davis 91, Campbell 85, Morgan 72, Clarke 64.
Now let's water it
Session runs notes to flashcards to quiz back-to-back.
Where this comes from
- CSEC Information Technology Syllabus (CXC 30/G/SYLL 08, revised 2000, 2008, 2013) · Caribbean Examinations Council (CXC) · Section 7, Specific Objective 11 · Syllabus scope
- Calc Guide 7.6 (LibreOffice 7.6 Community) · The Document Foundation (LibreOffice Documentation Team) · Chapter 2, Sorting records, pp 76-78, checked against (https://documentation.libreoffice.org/assets/Uploads/Documentation/en/CG7.6/CG76-CalcGuide.pdf) · Facts
- Calc Guide 7.6 (LibreOffice 7.6 Community) · The Document Foundation (LibreOffice Documentation Team) · Chapter 1, Spreadsheets, sheets, and cells, p 17, checked against (https://documentation.libreoffice.org/assets/Uploads/Documentation/en/CG7.6/CG76-CalcGuide.pdf) · Facts