Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How do I sort a hash by the hash key?
How do I sort a hash by the hash key?
✍: Guest
Suppose we have a class of five students. Their names are kim, al, rocky, chrisy, and jane. Here's a test program that prints the contents of the grades hash, sorted by student name: #!/usr/bin/perl -w %grades = ( kim => 96, al => 63, rocky => 87, chrisy => 96, jane => 79, ); print "\n\tGRADES SORTED BY STUDENT NAME:\n"; foreach $key (sort (keys(%grades))) { print "\t\t$key \t\t$grades{$key}\n"; } The output of this program looks like this: GRADES SORTED BY STUDENT NAME: al 63 chrisy 96 jane 79 kim 96 rocky 87 }
2013-09-03, 1720👍, 0💬
Popular Posts:
Assuming that the structure of a table shows two columns like this: --------+------------+-- ----+---...
How many types of validation controls are provided by ASP.NET ? There are six main types of validati...
How To Increment Dates by 1? - Oracle DBA FAQ - Understanding SQL Basics If you have a date, and you...
Enable ASP.NET polling using “web.config” file Now that all our database side is configured in order...
How do we access attributes using “XmlReader”? Below snippets shows the way to access attributes. Fi...