EmEditor (text editor) Forum Index
   Questions and Answers about Macros
     sort lines according to their length
Register To Post

Flat Previous Topic | Next Topic
Poster Thread
Yutaka
Posted on: 2/7/2013 3:54 pm
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2401
Re: sort lines according to their length
Hello,

This macro should sort the selected text from long to short.

document.selection.text = ((document.selection.text.split("\n")).sort(function(a,b){return b.length-a.length})).join('\n');



If you want to sort lines from short to long, please use this:

document.selection.text = ((document.selection.text.split("\n")).sort(function(a,b){return a.length-b.length})).join('\n');


Please select the whole document (CTRL + A) before you run this macro if you want to sort the entire document.

Thanks!


----------------
Yutaka Emura
Developer of EmEditor
http://www.emeditor.com/

Flat Previous Topic | Next Topic


Subject Poster Date
   sort lines according to their length spiros 2/3/2013 6:03 am
     Re: sort lines according to their length Yutaka 2/4/2013 9:59 am
       Re: sort lines according to their length spiros 2/5/2013 12:29 am
         Re: sort lines according to their length Yutaka 2/5/2013 10:18 am
           Re: sort lines according to their length spiros 2/5/2013 3:29 pm
           » Re: sort lines according to their length Yutaka 2/7/2013 3:54 pm
               Re: sort lines according to their length spiros 2/10/2013 2:12 pm

Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文