We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

How to sort anything

Formale Metadaten

Titel
How to sort anything
Untertitel
Keeping your data organized with "sorted" and custom functions
Serientitel
Anzahl der Teile
130
Autor
Lizenz
CC-Namensnennung - keine kommerzielle Nutzung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben
Identifikatoren
Herausgeber
Erscheinungsjahr
Sprache

Inhaltliche Metadaten

Fachgebiet
Genre
Abstract
Sorting is one of those things that we take for granted in Python. The built-in "sorted" function knows how to sort any iterable of objects that are themselves sortable. But hiding behind that simple description is a great deal of depth. In this talk, I'll go deep into what it means to sort, and how we can sort any collection of Python data. We'll see how you can use custom functions to sort built-in data structures in new and interesting ways. And we'll see how you can design your own custom classes such that they will sort in just the way you want. After watching this talk, you'll have a better understanding of sorting, built-in data structures, function objects, and how "magic methods" affect the our Python classes. Moreover, you'll be able to write clearer, shorter, and more easily understood code. Topics I'll address in this talk: - "sorted" and Timsort - Sorting a list of simple structures - Reversing the direction with "reverse" - Custom sorting with "key" - Stable sort - Sorting a list of dicts - Using "lambda" - Using operator.itemgetter - Sorting a list of named tuples - Sorting a list of objects - Making your object sortable - The functools.total_ordering decorator This is an intermediate-level talk; I'll assume that anyone attending knows how to write functions, classes, and methods.