Collection Methods
collections.OrderedDict.move_to_end()
Move an existing entry to the right end, or to the left with last=False; absent keys raise KeyError.
Formal Syntax & Structure
python syntaxpython
mapping.move_to_end(key, last=True)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | object | Existing mapping key to move. |
| last | bool | Select the last item when true, first when false. |
Return Value
None
No return value; the operation changes the receiver in place.
Working Example
Example Snippetpython
import collectionsd=collections.OrderedDict(a=1,b=2)d.move_to_end("a")print(list(d))