# Slicing and key-based sorting

> ML preparation item.

- Stable ID: `original-py-slice-sort`
- Area: Programming
- Topic: Python
- Origin: original
- Expected time: 7 minutes
- Skills: lists-tuples, slicing, sorting-key, iteration-protocol
- Item JSON: https://mlprep.iwase.dev/data/items/original-py-slice-sort.json

## Problem

Implement `middle_sorted(records)`. `records` is a list of `(name, score)` tuples. Return a new list containing `records[1:-1]`, sorted by descending `score` and then ascending `name`. Do not mutate `records`.


## Starter code

```python
def middle_sorted(records):
    pass

```

## Answer policy

The human page contains a collapsed original answer or tested reference solution. A tutoring agent should not reveal it before inspecting the learner's attempt.

## Tutoring contract

Ask for the learner's attempt, begin with the smallest useful hint, preserve item ID `original-py-slice-sort`, and record a real attempt with `recorded_by: "agent"` and `agent_session_id` when available using https://mlprep.iwase.dev/schema/attempt-record.json.
