title: Accent-insensitive sorting in MySQL
body: <p>I am trying to achieve accent and case-insensitive sorting in MySQL. Following the instructions in the manual, this is supposed to work with the utf8 character set and utf8_general_ci collation. </p>
  
  <p>When I follow the example in the manual (<a href="http://dev.mysql.com/doc/refman/5.1/en/charset-collation-implementations.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.1/en/charset-collation-implementations.html</a>) under "Collations for Unicode multi-byte character sets" I do not get the same results:</p>
  
  <pre><code>Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 679877
  Server version: 5.1.41-log MySQL Community Server (GPL) by Remi
  
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  
  mysql&gt; SET NAMES 'utf8' COLLATE 'utf8_general_ci';
  Query OK, 0 rows affected (0.00 sec)
  
  mysql&gt; SELECT 'a' = 'A', 'a' = 'À', 'a' = 'á';
  +-----------+-----------+-----------+
  | 'a' = 'A' | 'a' = 'À' | 'a' = 'á' |
  +-----------+-----------+-----------+
  |         1 |         0 |         0 |
  +-----------+-----------+-----------+
  1 row in set (0.00 sec)
  
  mysql&gt; 
  </code></pre>
  
  <p>In the example in the manual, those are all 1.</p>
  
  <p>It also fails to treat accented characters equally when I try to set the collation directly in a query.  In this example, the table is using latin1 and I'm converting to utf8.</p>
  
  <pre><code>mysql&gt; select * from test;
  +----------+
  | k        |
  +----------+
  | Cárdenas |
  | Cardozo  |
  | Corbin   |
  | Cabrero  |
  +----------+
  
  mysql&gt; select k from test order by convert(k using utf8) collate utf8_general_ci
  ;
  +----------+
  | k        |
  +----------+
  | Cabrero  |
  | Cardozo  |
  | Corbin   |
  | Cárdenas |
  +----------+
  4 rows in set (0.00 sec)
  </code></pre>
  
  <p>It should be ignoring the accent over the 'a' in the last entry and sorting it second.  Any ideas what I'm doing wrong? </p>