dict sort in Python based on key, value

#!/usr/bin/env python3

key_value ={}
key_value[2] = 56
key_value[1] = 2 
key_value[5] = 12 
key_value[4] = 24
key_value[6] = 18      
key_value[3] = 323

### sort with key
print(sorted(key_value.items(), key=lambda d:d[0]))
print(sorted(key_value.items(), key=lambda d:d[0], reverse=True))

### sort with value
print(sorted(key_value.items(), key=lambda d:d[1]))