☰ Contents · Computing

Sorting data

Lessons 28 · 1 lessons · B. Boltayev, A. Azamatov, A. Asqarov, M. Sodiqov, G. Azamatova. Fundamentals of Informatics and Computer Technology, Grade 8. Second edition. “O‘zbekiston milliy ensiklopediyasi” State Scientific Publishing House, Tashkent, 2015
28

Sorting data

Textbook: pp. 120–123
GoalUnderstands a list as fields and records and sorts a table by one or several fields in ascending or descending order.
New words
field: a column of a list, named by its header · maydonrecord: one row of a list · yozuvsorting: arranging the records by the values of a field · tartiblashascending order: from smallest to largest, A to Z · o‘sish tartibi
Explanation

In Excel a list is treated like a database: a column is a field, a column header is the field name, and each row is a record. Sorting arranges the records by the value of a chosen field in ascending (smallest to largest, A to Z) or descending (largest to smallest) order; the number of records does not change. Select the whole table or one cell of it and use Data → Sort; the “my data has headers” tick keeps the first row out of the sorting. If you select and sort only one column, that column moves while the others stay, and names end up beside another person’s data. In a multi-field sort, records with equal first-field values are ordered by the second field, then the third. The letter order depends on the language: o‘, g‘, sh and ch may be placed differently from what you expect, depending on the language setting, so check the result; to be able to return to the original order, add a column of numbers beforehand.

Worked examples
List (city, temperature °C): Nukus 28, Bukhara 31, Nukus 25, Andijan 28. City ascending, then temperature descending: Andijan 28; Bukhara 31; Nukus 28; Nukus 25.
A mistake: if only the names column is selected and sorted, the names go into alphabetical order but the marks stay where they were – each child gets someone else’s mark. That is why the whole table is sorted.
Class activity

“Sorting test”: a group builds a table of 6 product names and prices, sorts by name and then by price, and checks the result together.

Practice
1
What do “field” and “record” mean in a list?
2
The marks 78, 92, 65, 88 are sorted in descending order. Which number is third?
3
A table with 12 records and 1 header row is sorted. How many rows does it have afterwards?
4
Why sort by a second field too when surnames are equal?