Skip to content

Latest commit

 

History

History
50 lines (27 loc) · 652 Bytes

Convert_Hash_To_An_Array.md

File metadata and controls

50 lines (27 loc) · 652 Bytes

CodeWars Python Solutions


Convert Hash To An Array

Convert a hash into an array. Nothing more, Nothing less.

{name: 'Jeremy', age: 24, role: 'Software Engineer'}

should be converted into

[["name", "Jeremy"], ["age", 24], ["role", "Software Engineer"]]

Note: The output array should be sorted alphabetically.

Good Luck!


Given Code

def convert_hash_to_array(hash):
    pass

Solution

def convert_hash_to_array(hash):
    return sorted([[k, v] for k,v in hash.items()])

See on CodeWars.com