#!/usr/bin/perl -w use strict ; my @array = ( "row #1\t106\thello", "row #2\t101\tgoodbye", "row #3\t104\thi again!" ) ; my $datafields = 3 ; my $sort = 1 ; my $sortby = "number" ; print join ("\n", sort {&sort_func} @array) ; #### my $col = 1 ; # this is called "$sort" and "$item_no" in the original my @sorted = sort {(split ("\t", $b)) [$col] <=> (split ("\t", $a)) [$col]} @array ;