title: How to maintain insertion order using UUID
body: <p>On a pet project I started to work with UUIDs.
  The application is fairly simple, it adds data in a MySQL database with <code>binary(16)</code> primary keys.</p>
  
  <p>To generate PK's I'm using <a href="http://wiki.fasterxml.com/JugHome" rel="noreferrer">JUG</a> this way :</p>
  
  <p><code>UUID uuid = Generators.timeBasedGenerator().generate();</code></p>
  
  <p>Then I convert it to a byte array :</p>
  
  <p><code>byte[] b = UUIDUtil.asByteArray(uuid);</code></p>
  
  <p>The problem now is that I have no idea on the insertion order of my rows.
  If I sort my rows by the ID some recent rows comes before older rows (according to a <code>DATETIME</code> field)</p>
  
  <p>What should I do to be able to keep the insertion order of my rows (for sorting purpose) ?</p>
  
  <p>Illustration of the problem, UUIDs are sorted ASC, I'm expecting created_at being in the same order.</p>
  
  <p><code>select hex(id), created_at from myTable order by id</code></p>
  
  <pre><code>+----------------------------------+---------------------+
  | hex(id)                          | created_at          |
  +----------------------------------+---------------------+
  | 0913FF1FC53911E39D8D6F7C246EE143 | 2014-04-16 09:30:50 |
  | 09378CB1C53911E39D8DD94CAEA8D23F | 2014-04-16 09:30:50 |
  | 094A9F83C53911E39D8DDF087D0ED31A | 2014-04-16 09:30:51 |
  | 0CBE40D5C0B711E38172B9CB0C485EE3 | 2014-04-10 15:50:17 |
  | 0CBF5247C0B711E3817277CAF5E1D5B5 | 2014-04-10 15:50:17 |
  | 0CC03CA9C0B711E381721BA12057F9E2 | 2014-04-10 15:50:17 |
  | 0CC14E1BC0B711E381720505D5FFDCD3 | 2014-04-10 15:50:17 |
  | 0CC2387DC0B711E38172F9A6B29EB613 | 2014-04-10 15:50:17 |
  | 0CC349EFC0B711E381723D1DB8515E3F | 2014-04-10 15:50:17 |
  | 0CC43451C0B711E3817257D8AFFD09B8 | 2014-04-10 15:50:17 |
  | 0CC545C3C0B711E381729B3CB87CD707 | 2014-04-10 15:50:17 |
  | 0CC8C835C0B711E38172CDA11992F9BC | 2014-04-10 15:50:17 |
  | 0E33A6B5C08B11E396829782BD5365D2 | 2014-04-10 10:35:22 |
  | 0E368CE7C08B11E39682A9F63D5EF0E6 | 2014-04-10 10:35:22 |
  | 0E383A99C08B11E396825D6048BFC696 | 2014-04-10 10:35:22 |
  | 128DD6C5C53911E39D8D7577DB523A2C | 2014-04-16 09:31:06 |
  +----------------------------------+---------------------+
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Just to clarify, I of course know and am used to <code>auto_increment</code> PK's, I just wanted to see how it was achievable to work without them. (In case it is !)</p>