title: Glob is not reading files in order
body: <p>I am doing model inferencing on images. I have a folder with images, named <em>image_0</em>, <em>image_1</em> and so on. I need to read each image, do the inference job and then save them with the same name in order to merge them together to form a bigger image. To read the images, I use the next code:</p>
  <pre><code>for image_path in sorted(glob.glob(r'/patches/images/*.png')):
      image_np = load_image_into_numpy_array(image_path)
  </code></pre>
  <p>After the inference, to save each image I do:</p>
  <pre><code>cv2.imwrite(f'patches/new/image_{n}.png', im_bgr)
  </code></pre>
  <p>The line above is in the same <code>for</code> loop as <code>glob</code>.</p>
  <p><code>n</code> is the number of the image, indicated by a counter in each iteration.</p>
  <p>The problem is that <code>glob</code> is not reading the images in the correct order (even if I put <code>sorted</code> before it, as I read in other questions), so when I merge them together, instead of being like this (each number represents an image):</p>
  <pre><code>1   2   3
  4   5   6
  7   8   9
  </code></pre>
  <p>the result is not ordered:</p>
  <pre><code>1   6   8
  2   9   4
  5   7   3
  </code></pre>
  <p><a href="https://i.stack.imgur.com/bAwPH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bAwPH.jpg" alt="enter image description here" /></a></p>
  <p>So, how can I make <code>glob</code> to read the images in the correct order?</p>
  <p>Thank you!!!</p>