---
id: python-lists-sort
title: "Python Lists Sort"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["Sort Lists", "파이썬 리스트 정렬"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.9
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["python", "programming", "w3schools", "lists", "sort"]
raw_sources: ["https://www.w3schools.com/python/python_lists_sort.asp"]
applied_in: []
github_commit: ""
---

# [[Python Lists Sort]]

## 🎯 한 줄 통찰 (One-line insight)
sort() is case-sensitive by default (capitals sort before lowercase), but passing a key function like `str.lower` or a custom function fixes that, while reverse() simply flips the current order without re-sorting. [S1]

## 🧠 핵심 개념 (Core concepts)
- **`sort()`** — sorts the list in place, alphanumerically ascending by default. [S1]
- **`reverse=True` argument** — sorts descending. [S1]
- **`key=function` argument** — customizes the sort criterion; the function returns a number used for ordering (lowest first). [S1]
- **Case sensitivity** — default sort puts all capital letters before lowercase letters. [S1]
- **`key=str.lower`** — a built-in function used as the key for case-insensitive sorting. [S1]
- **`reverse()`** — reverses the current order of the list (not the same as descending sort). [S1]

## 🧩 추출된 패턴 (Extracted patterns)
- **Custom sort via distance function** — `key = myfunc` where `myfunc` returns `abs(n - 50)` sorts numbers by closeness to 50 rather than by raw value — showing `key` can encode arbitrary sort logic. [S1]

## 📖 세부 내용 (Details)
- Ascending (default): `thislist.sort()`. [S1]
- Descending: `thislist.sort(reverse = True)`. [S1]
- Custom key function: `def myfunc(n): return abs(n - 50); thislist.sort(key = myfunc)`. [S1]
- Case-insensitive: `thislist.sort(key = str.lower)`. [S1]
- Reverse (not sort): `thislist.reverse()`. [S1]

## ⚖️ 모순 및 업데이트 (Contradictions & updates)
소스에서 모순되는 정보는 발견되지 않음.

## 🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — 대소문자 무시 정렬은 실무에서 텍스트 정렬 시 흔히 필요한 패턴이다. [S1]

## 💻 코드 패턴 (Code patterns)
Case-insensitive and custom-key sorting (Python):
```python
thislist = ["banana", "Orange", "Kiwi", "cherry"]
thislist.sort(key=str.lower)

def myfunc(n):
    return abs(n - 50)
numlist = [100, 50, 65, 82, 23]
numlist.sort(key=myfunc)
```

## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.90
- **중복 검사 결과:** 신규 생성 (New discovery)

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[Python Tutorial]]
- **관련 개념:** [[Python Lists]], [[Python Lambda]], [[Python Functions]]
- **참조 맥락:** 리스트 정렬 커스터마이징 — key 함수 개념은 이후 Lambda 챕터와도 연결된다.

## 📚 출처 (Sources)
- [S1] W3Schools — Python - Sort Lists — https://www.w3schools.com/python/python_lists_sort.asp

## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Sort Lists" page (Astra wiki-curation, P-Reinforce v3.1 format).
