- AuthorPosts
- December 25, 2013 at 5:07 am #17726TransUAParticipant
Hello.
Need a macro to sort the rows in a random large files (10-1000 Mb). RAM of 2 Gb :-).
Thanks!December 25, 2013 at 6:48 am #17727StefanParticipantHi TransUA,
to sort the lines alphabetically from A to Z, you can utilize the build-in functions from the Edit menu.
–To randomly shuffle the lines, this basic JavaScript functions should work:
//Randomly shuffle lines
//1.) select some text. 2.) execute this JavaScript macro. 3.) Done!
strSelText = document.selection.Text;
strLinebreak = “\r\n”;
arrLinesArray = strSelText.split(strLinebreak);
arrLinesArray.sort(function random(){return 0.5 – Math.random()});
arrOut = arrLinesArray.join(strLinebreak);
document.selection.Text = arrOut;Store that above as shuffle.jsee into the EmEditor folder and load it via menu Macros > Select…
Next select your text to shuffle and execute Macros > shuffle.jseeNote:
you can find discussions about “better” or faster sort algorithms in the net and exchange my random function by another one.HTH?
- AuthorPosts
- You must be logged in to reply to this topic.