Lesson Module · Detail

Sort lists (The Ball Challenge)

This module deepens the work with lists through copying, sorting, and position-based placement of objects. It supports the structured modeling of data processing steps and their implementation in program flows.

Time 10 minutes
Format rpgDungeon
Language Python 2 (CE)
Tasks 1
Preview image: Sort lists (The Ball Challenge)

Introduction (Original excerpt)

Linus Lag almost got everything right – but not quite. He collects all the balls and puts them back in their places. Unfortunately, he sorts them incorrectly and puts them down at the wrong spot as well. Your task is to correct the code.

Didactic classification

Subjective goal

Central to this module is the structured processing of data within lists. It introduces how existing lists can be copied to obtain original states for later processing steps. Building on this, list sorting is implemented based on a specific attribute and converted into concrete action logic. Learners must consider the relationship between data structure and physical placement in the model. The task illustrates that changes to data structures have immediate effects on subsequent process steps. This makes the connection between the data model and algorithmic implementation explicitly experiential.

Competence development

Didactic added value in teaching

Flow of the lesson unit

1

Correct sorting

In this step, an existing list processing is analyzed and adapted. The sorting must be switched to a suitable attribute and the subsequent storage logic corrected. This makes the connection between the sorting criterion and the subsequent position determination in the program flow clear.

  • Didactic focus: Sorting of structured data
  • Typical challenge: Assignment of data attributes to storage logic

Work assignment (excerpt)

  1. Sorting on the attribute name rearrange.
  2. Adjustments for correct storage through rotations.

Example (excerpt)

This fragment shows the sorting of a list copy based on a specific attribute as a basis for subsequent storage.

1
2
3
4
5
unsortiert = inventar.copy()
sortiert = sorted(unsortiert, key=lambda d: d["name"])
for ding in sortiert:
    platz = unsortiert.index(ding)
    ablegen(platz)

Hints for classroom practice

This module connects list operations with step-by-step implementation and creates a clear basis for competence-oriented results.

The clear task structure supports lesson organization and facilitates result verification; differentiation is possible through extended sorting commands.

Request a demo access and test the module in your own course context.