Created
January 17, 2012 21:08
-
-
Save vladocar/1628874 to your computer and use it in GitHub Desktop.
Order Layers Alphabetically in Photoshop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?