Past-paper question · 2019 May-June · Paper 33 · Q2(a)

Question 2(a) 2019 · May-June · Paper 33 · 4 marks

Original past-paper question for 2(A)
Original past-paper question for 2(A)
Reveal official mark-scheme answer Official mark-scheme answer for 2(A)

Official answer for Question 2

Part (a)

✓
Four from:

Question 4

✓
Function sort () treats values as strings not numbers
✓
Strings are sorted alphabetically
✓
Strings are not sorted numerically
✓
a is before / ‘lower’ than b so list 1 is sorted alphabetically by the first letter
✓
and then by the second etc.
✓
in list 2, the list is also sorted alphabetically so e.g. 1111 is before 12
✓
because 2 is ‘bigger’ than 1
✓
The third character in 1111 has no match so is ‘bigger’ than 12
✓
3666 is before 37 because while the 3s match, and 6 is before 7, there is no
✓
match for the second 6 so it is ‘bigger’ than no number.

Mark scheme 9626_s19_ms_33.pdf →

Show text version of question

Question 2

Part (a)

Question 2

In JavaScript code, the sort() function is used to sort lists into ascending order.

Part (a)

Explain, in detail, why, when using the sort() function, the list in Fig. 2.1 is sorted correctly, but

the list in Fig. 2.2 is not.

Before sorting After sorting Before sorting After sorting

fly ant 1345 1111 cockroach beetle 3666 12 ant butterfly 1111 1345 butterfly cockroach 23 23 moth fly 37 3666 beetle moth 12 37

Fig. 2.1 Fig. 2.2

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................

[4]
Topic relevance

Why this question appears here

98% assigned-topic match · Programming for the web

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9626_s19_qp_33.pdf

Keep practising this topic