in reply to Trying to write simple program

Loop through your input array, splitting on whitespace into numbers and descriptions. Stuff them into a Hash-of-Arrays data structure, with descriptions as keys and numbers as arrays. Then loop through the HoA, printing as desired:
use strict; use warnings; my @ins = ( '00001 Description1', '00002 Description2', '00003 Description1' ); my %data; for (@ins) { my ($num, $desc) = split; push @{ $data{$desc} }, $num; } for (sort keys %data) { print join("\t", @{ $data{$_} }), "\t$_\n"; } __END__ 00001 00003 Description1 00002 Description2

See also perldsc