Macro for EmEditor to sort lines according to length

spiros · 1 · 1501

spiros

  • Administrator
  • Hero Member
  • *****
    • Posts: 854566
    • Gender:Male
  • point d’amour
Macro for EmEditor (my favourite text editor) to sort lines according to length

Save the macro of your choice below in a txt file in My Macros folder (found in My Documents). Rename the file to sort.jsee (or use the attached after you unzip it).

First select the text. Then run any of these macros:

Sort the selected text from long to short
Code: [Select]
document.selection.text = ((document.selection.text.split("\n")).sort(function(a,b){return b.length-a.length})).join('\n');
Sort the selected text from short to long
Code: [Select]
document.selection.text = ((document.selection.text.split("\n")).sort(function(a,b){return a.length-b.length})).join('\n');
This was tested on an 80 MB file with maximum line length of 80,000 characters and it took a couple of seconds to run.
« Last Edit: 11 Feb, 2013, 08:28:24 by spiros »


 

Search Tools