title: Sorting files in numerical order in Go
body: <p>I am reading a directory, and with this I've noticed that if I have files which are ordered by number (1, 2, 3, 4...) then it seems to use some alphabetic ordering.</p>
  
  <p>Say that I have 13 files (named 1.md, 2.md, 3.md...), the ordering would look like: 1, 10, 11, 12, 13, 2, 3, 4...; The current code I am using to produce this order is:</p>
  
  <pre><code>files, _ := ioutil.ReadDir(my_dir)
      for _, f := range files {
          fmt.Println(f.Name())
      }
  </code></pre>
  
  <p>The ordering I am looking for is 1, 2, 3, ... 9, 10, 11, 12, 13.</p>
  
  <p>How can I get a strict numerical sorting on these files? Bear in mind that each file is named N.md where N is guaranteed to be an integer greater than or equal to 0.</p>
  
  <p>Thank you.</p>