<s> from textplot . utils import sort_dict <EOL> from collections import OrderedDict <EOL> def test_descending ( ) : <EOL> """<STR_LIT>""" <EOL> d = OrderedDict ( [ <EOL> ( '<STR_LIT:a>' , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT:b>' , <NUM_LIT:2> ) , <EOL> ( '<STR_LIT:c>' , <NUM_LIT:3> ) <EOL> ] ) <EOL> desc = sort_dict ( d ) <EOL> assert list ( desc . items ( ) ) == [ <EOL> ( '<STR_LIT:c>' , <NUM_LIT:3> ) , <EOL> ( '<STR_LIT:b>' , <NUM_LIT:2> ) , <EOL> ( '<STR_LIT:a>' , <NUM_LIT:1> ) <EOL> ] <EOL> def test_ascending ( ) : <EOL> """<STR_LIT>""" <EOL> d = OrderedDict ( [ <EOL> ( '<STR_LIT:c>' , <NUM_LIT:3> ) , <EOL> ( '<STR_LIT:b>' , <NUM_LIT:2> ) , <EOL> ( '<STR_LIT:a>' , <NUM_LIT:1> ) <EOL> ] ) <EOL> asc = sort_dict ( d , desc = False ) <EOL> assert list ( asc . items ( ) ) == [ <EOL> ( '<STR_LIT:a>' , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT:b>' , <NUM_LIT:2> ) , <EOL> ( '<STR_LIT:c>' , <NUM_LIT:3> ) <EOL> ] </s>
