Key function
A key function is a callable that maps an item to a value used to compare, order, identify, index, or match it.
D3.js in Action, Third Edition
A key function computes stable identity keys that allow data-bound elements to be matched with corresponding data items across updates.
- How it is used
- Maintains stable data-element identity while filtering an interactive D3 scatterplot.
- How deep it goes
- Explains positional matching, uid-based matching, and integration with D3 data() and join(), without descending into API internals.
- Examples
- Uses filtered cetacean circles keyed by uid and compares D3 matching with React list keys.
- What you can do after
- Apply it via D3's data() method to preserve element identity during dataset updates and control resulting selections.
Read how D3.js in Action, Third Edition explains key function →
The Quick Python Book, Fourth Edition
A key function is a callable that maps each item to a value used to determine that item's ordering during sorting.
- How it is used
- Customizes sorting when default comparison does not match the desired ordering.
- How deep it goes
- Explains the one-argument return rule, named and lambda syntax, applications, and repeated-call performance cost.
- Examples
- Demonstrates sorting words by length, text case-insensitively, or by a substring of each line.
- What you can do after
- Apply it via Python sorting methods to order items by a computed property.
Read how The Quick Python Book, Fourth Edition explains key function →
Related concepts
- maximumused by · A maximum is the greatest value in a set under a specified ordering, or the greatest value permitted by a specified constraint.
- sorting algorithmused by · A sorting algorithm is a procedure that rearranges elements of a collection into an order determined by an ordering criterion.
- data()configures · data() is a D3 selection method that associates an array of data values with the selected document elements.
- lambdaimplemented by · A lambda is a language construct that defines an unnamed function or callable, often as a value.
- sortedused by · sorted is a Python built-in function that returns a new list containing an iterable’s elements in sorted order without modifying the original iterable.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

