title: How to order data by custom algorithm in MySQL?
body: <p>I have a hierarchical table with some data in it. I've handled sorting them in a hierarchical way but there is a bug in it. I use a field named <code>Path</code> to do this. let's look at the table first:
  <a href="https://i.stack.imgur.com/IvD6s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IvD6s.png" alt="enter image description here"></a></p>
  
  <p>The problem here is that mysql compares each pair of Paths as text. That if you look at those last two rows, 15 is bigger than 6 and should be swapped with the row under it.</p>
  
  <p>My question is how can I compare each part of the path as numbers separated by dots?</p>