Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17726

    TransUA
    Participant

    Hello.
    Need a macro to sort the rows in a random large files (10-1000 Mb). RAM of 2 Gb :-).
    Thanks!

    #17727

    Stefan
    Participant

    Hi 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.jsee

     

    Note:
    you can find discussions about “better” or faster sort algorithms in the net and exchange my random function by another one.

     

    HTH?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Share with friends... Tweet about this on TwitterShare on FacebookShare on Google+Email this to someone