7 kyu
Sorting Dictionaries
3,548 of 5,322cmgerber
Description:
Python dictionaries are inherently unsorted. So what do you do if you need to sort the contents of a dictionary?
Create a function that returns a sorted list of (key, value)
tuples (Javascript: arrays of 2 items).
The list must be sorted by the value
and be sorted largest to smallest.
Examples
sort_dict({3:1, 2:2, 1:3}) == [(1,3), (2,2), (3,1)]
sort_dict({1:2, 2:4, 3:6}) == [(3,6), (2,4), (1,2)]
Sorting
Lists
Fundamentals
Similar Kata:
Stats:
Created | Jul 31, 2014 |
Published | Jul 31, 2014 |
Warriors Trained | 10265 |
Total Skips | 1051 |
Total Code Submissions | 15930 |
Total Times Completed | 5322 |
Python Completions | 3548 |
JavaScript Completions | 1658 |
Haskell Completions | 329 |
Total Stars | 104 |
% of votes with a positive feedback rating | 91% of 574 |
Total "Very Satisfied" Votes | 489 |
Total "Somewhat Satisfied" Votes | 69 |
Total "Not Satisfied" Votes | 16 |