# File Listing Order

**URL:** https://discourse.processing.org/t/file-listing-order/7148
**Category:** Coding Questions
**Created:** [January 4, 2019, 4:43am UTC](https://discourse.processing.org/t/file-listing-order/7148 "2019-01-04T04:43:52Z")
**Posts on this page:** 1
**Showing post:** 41

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [January 8, 2019, 1:43pm UTC](https://discourse.processing.org/t/file-listing-order/7148/41 "2019-01-08T13:43:32Z")

</div>

> [@Architector\_4](#):
>
> I forgot what the actual topic was about and forgot to include `sort(images);`

[Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/util/Arrays.html#sort(java.lang.Object[])](http://Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/util/Arrays.html#sort(java.lang.Object%5B%5D))

```java
static final String PICS_EXTS = "extensions=,png,jpg,jpeg,gif,tif,tiff,tga,bmp,wbmp";

static final float FPS = .25;

PImage[] images;

void setup() {
  size(1200, 600);
  frameRate(FPS);
  imageMode(CENTER);

  final File dir = dataFile("");
  println(dir);

  String[] imagePaths = {};
  int imagesFound = 0;

  if (dir.isDirectory()) {
    imagePaths = listPaths(dir.getPath(), "files", "recursive", PICS_EXTS);
    imagesFound = imagePaths.length;
    java.util.Arrays.sort(imagePaths); // sorts the array in place
  }

  printArray(imagePaths);
  println("Found", imagesFound, "image(s)");

  for (int i = 0; i < imagesFound; images[i] = loadImage(imagePaths[i++]));
}

void draw() {
  clear();
  image(images[frameCount % images.length], width>>1, height>>1);
}

```

---

_[View the full topic](https://discourse.processing.org/t/file-listing-order/7148)._
