Let us consider the following code to loop over the keys from a dictionary in Python:
for key in a_dict.keys():This would be nearly the same in Perl:
for my $key in (keys %a_dict) {And Perl 6*:
for %a_dict.k -> my $key {But now you say: I want to have in a sorted rather then arbitrary order
(
Read more... )
Comments 4
for val in sorted(dic.keys()): ...
or even
for val in sorted(dic): ...
Reply
Reply
Reply
"sorted(dic.items())" is legal, because it sorts pairs by the first column and then the second column.
Reply
Leave a comment