3 Replies Latest reply on Mar 30, 2012 1:15 PM by Josh000000

    Sorting text frames by height

    Josh000000 Level 1

      Having some trouble sorting text frames by height with the javascript sort function... is this possible?

       

      var doc = app.activeDocument;
      
      
      function tallestFrame(page) {
                var frames = page.textFrames.everyItem().getElements();
                frames.sort(function(a,b) {
                          var aHeight = (frames[a].geometricBounds[2] - frames[a].geometricBounds[0]);
                          var bHeight = (frames[b].geometricBounds[2] - frames[b].geometricBounds[0]);
                          return aHeight - bHeight;
                });
      }
      
      
      alert(tallestFrame(doc.pages[0]));