Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/util/Arrays.html#sort(java.lang.Object[])
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);
}