http://qs1969.pair.com?node_id=213151


in reply to MySQL Alphabetical order with DBI

You could do that, splitting on the space in the name column and then running a sort in Perl, but it's going to lead to all sorts of problems if/when variant names crop up. What happens if you have a name like John Jacob Ezekiel Smith.....?

Personally, I would restructure the database and split the column into consituents. FirstName (varchar 50), LastName (varchar 50), pageref (??). That way, you can use SQL to perform the sort (e.g. SELECT * FROM authors ORDER BY LastName) and eliminate the possibility of sorting on the wrong name. You would also see a speed performance increase doing it this way.

update: a little slow on the keyboard this morning. Asim makes a good point about Lingua::EN::NameParse