#!/usr/bin/perl use strict; use warnings; my @names; while (<DATA>){ chomp; m/^(\d+)\s+(.*)/; push @names, [$1, $2]; } @names = sort { $a->[1] cmp $b->[1] } @names; for (@names){ print "$_->[0] $_->[1]\n"; } __DATA__ 1 Charlie 1 Edward 2 Bob 2 Alfred 3 Barry
In reply to Re: How to sort?
by moritz
in thread How to sort?
by redss
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |