#!/usr/bin/perl use strict; use warnings; use 5.010; chomp( my @words = ); @words = sort { substr( $a, 1, 1 ) cmp substr( $b, 1, 1 ) } @words; say for @words; __DATA__ How about sorting an array of words by the second character every word