Question: I want make a specific element of each dictionary the first element in a list of dictionaries. How would I do this, or is it even possible given that dictionaries are unordered?

I don't want to use .sort() by itself or OrderedDict because both will not bring the desired element to the top of the keys as the keys are alphabetically ordered. Is there a way to use the lamba keyword in combination with sort in Python 2.7 to do this?

Ex:

I want `b` to be the first key 

```
{'a': 1, 'b': 2, 'c': 3}

{'b': 2, 'a': 1, 'c': 3}

```

---

CONTEXT:

I have a large set of dictionaries where each dictionary represents a bunch of info about a job. Each dictionary has a code that identifies the job. My superior would like to have this code moved to the top of its dictionary.

Answer: 
Wrap your dict in a list and move your code out. Instead of

```
data = {'code':'this is the code', 'some':'other', 'stuff':'here'}

```

do

```
data = ['this is the code', {'some':'other', 'stuff':'here'}]

```
As others have pointed out, Python's dictionaries are now ordered (by insertion order) since Python 3.6. The cleanest way I know to move a single item to the front of a dictionary is to use `pop()`:

```py
d = {'a': 1, 'b': 2, 'c': 3}  # original dict
d = {'b': d.pop('b'), **d}  # new order
print(d)
# {'b': 2, 'a': 1, 'c': 3}

```

Python [guarantees left-to-right execution order](https://docs.python.org/3.3/reference/expressions.html#evaluation-order), so you know the `pop` takes place before expanding `**d`, which means `'b'` will occur at the front and not later in the `**d` expansion.

If you're going to be doing this a bunch and you don't want to write the key twice, or if the key is going to be a computed expression, you can make a helper function:

```py
def plop(d, key):
    return {key: d.pop(key)}

d = {'a': 1, 'b': 2, 'c': 3}  # original dict
d = {**plop(d, 'b'), **d}  # new order
print(d)
# {'b': 2, 'a': 1, 'c': 3}

```