Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Order Layers Alphabetically in Photoshop
var layers = activeDocument.layers;
var layersArray = [];
var len = layers.length;
// store all layers in an array
for (var i = 0; i < len; i++) {
layersArray.push(layers[i]);
}
// sort layer top to bottom
layersArray.sort();
for (i = 0; i < len; i++) {
layersArray[i].move(layers[i], ElementPlacement.PLACEBEFORE);
}
@dsharpminor

This comment has been minimized.

Copy link

@dsharpminor dsharpminor commented Nov 6, 2020

Thank you for sharing this piece of code. I was wondering how natural sort could be implemented? Right now the output looks like this:
1a, 10a, 2b. And I was wondering what could be done to make it 1a, 2b, 10a?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment