Preview:
const cleanSort = function(x,y)

{

    x = x.toLowerCase();

    y = y.toLowerCase();

    return x < y ? -1 : +(x!=y);

};

const sortInLayer = function(/*str*/name,  o,a,s)

{

    o = app.properties.activeDocument;

    if( !o ){ alert( "No document." ); return; }

    o = o.layers.itemByName(String(name));

    if( !o || !o.isValid ){ alert("No layer with that name."); return; }

    for

    (

        (a=(o=o.pageItems).everyItem().na
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter