I am trying to figure out how to sort an SQL query by Last Name. This is working except in the case of where a customers last name has a special character.
For example O'Maley.
If this last name is sorted with a last name of "Omar" for example the order should be:
O'Maley Omar
BUT since I use addslashes() in PHP before adding it into the database the sort is actually happening on O\'Maley and so the sort ends up being.
Omar O'Maley
Of course the \ is removed with stripslashes() before being displayed to the user.
How can I make this properly sort?