#!/usr/local/bin/perl use strict; use warnings; my $a = [1, 2, 5, 7, 4]; sub mySort($$) { my ($a,$b) = @_; $a <=> $b; } print "", (sort mySort @$a), "\n"; __END__ Output: 12457