in reply to custom sorting

As a side note, are you sure that names like 'Mary Beth Jenkins' or 'Sammy Davis Jr.' won't be in your text file?

If not, you might take pc88mxers code and change the last split line to:

my (@name) = split(/ /, $fullname); $last= pop @name; if ($last=~/(jr|sr)\.?/i) { $last= pop @name . ' ' . $last; }
Now if you also might have double surnames (like 'Mary Wayward Jenkins') you are out of luck. Changing all "Double Surnames" to "Double-Surnames" is then your only hope. Or doing that with the first names and changing above code somewhat