|
|
Question : sort hash in perl
|
|
%aList = ('car'=>300,'train'=>150,'truck'=>100,'bike'=>330);
I need to write a program to sort this by the order of key and value respectively without using the sort functions provided by the language
|
Answer : sort hash in perl
|
|
If you were interviewing with me, you'd be in trouble until you explained that you didn't really mean "sort the hash". The elements of the hash can be retrieved in a specific order, most commonly by sorting the keys. And there are modules that support expanded hash objects with additional properties, such as maintaining the insertion order.
|
|
|
|
|