title: Windows Explorer sort method
body: <p>I'm looking for an algorithm that sorts strings similar to the way files (and folders) are sorted in Windows Explorer. It seems that numeric values in strings are taken into account when sorted which results in something like</p>
  
  <pre><code>name 1, name 2, name 10
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>name 1, name 10, name 2
  </code></pre>
  
  <p>which you get with a regular string comparison.</p>
  
  <p>I was about to start writing this myself but wanted to check if anyone had done this before and was willing to share some code or insights. The way I would approach this would be to add leading zeros to the numeric values in the name before comparing them. This would result in something like</p>
  
  <pre><code>name 00001, name 00010, name 00002
  </code></pre>
  
  <p>which when sorted with a regular string sort would give me the correct result.</p>
  
  <p>Any ideas?</p>