#!/usr/bin/pugs use v6; my %hash = (a => 1, b => 2, c => 3, d => 4); say %hash;# prints a 1b 2c 3d 4 say ~%hash.keys.sort;#print a b c d say sort(keys(%hash)); #p5 style say ~%hash.values.sort;#print 1 2 3 4 say sort(values(%hash)); #p5 style say "num of elements in hash is " ~ +%hash;# prints 4 say %hash.pick.key;# pick any key say %hash.pick.value;#pick any value # print all key and value for (%hash.kv) -> ($key,$value) { say "hash key is $key val is $value "; } my @pairs; @pairs = %hash.pairs.sort; say @pairs;#prints a 1b 2c 3d 4 say @pairs[2].key;# prints c say @pairs[2].value;# prints 3 %hash.delete("a");# delete key a say %hash.exists("b");#prints 1 %hash.exists("x");