Removing first key value pair from hash
perl
Solution
The expression `(sort keys %hash)[0]` returns a string, so you can't just pass that to `delete`. You have to tell `delete` which hash you're deleting from. It should go like this:
delete $hash{(sort keys %hash)[0]};
Problem
I have a hash like this: ``` %hash = ('test' => 1, 'test1' => 2, 'test2' => 3,); ``` I want to sort this hash and delete the first key value pair from hash. If I do this, (sort keys %hash)[0], I get access to first key. However, how do I delete that key value pair? If I do ``` delete (sort keys %hash)[0] ``` Perl throws an error, delete argument is not a HASH or ARRAY element