Skip to content

Instantly share code, notes, and snippets.

@vladocar
Created January 17, 2012 21:08
Show Gist options
  • Save vladocar/1628874 to your computer and use it in GitHub Desktop.
Save vladocar/1628874 to your computer and use it in GitHub Desktop.
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);
}
@runasharp
Copy link

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