in reply to sorting hash alphabetically with numbering
Like this?:
#! perl -slw use strict; my %cities = ( Tucson => 'AZ', Boston => 'MA', Jackson => 'MS', Dixon => 'NM', Denton => 'TX', Cincinnati => 'OH', ); my @sorted = sort keys %cities; my $n = 0; printf "%d: %s, %s\n", ++$n, $_, $cities{ $_ } for @sorted; __END__ C:\test>1144458 1: Boston, MA 2: Cincinnati, OH 3: Denton, TX 4: Dixon, NM 5: Jackson, MS 6: Tucson, AZ
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sorting hash alphabetically with numbering
by reebee3 (Novice) on Oct 12, 2015 at 03:47 UTC | |
by kcott (Archbishop) on Oct 12, 2015 at 04:07 UTC |