Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #23819

    David
    Participant

    In CSV mode, we have already had some “sort” options, such as from A-Z, from Z-A, according to length of the string……But may I know if there’s a way to sort data randomly? Thanks!

    #23820

    Yutaka Emura
    Keymaster

    I just want to clarify. By “random sort”, do you mean shuffle lines (or cells) randomly? Then we will think about that in the future.

    #23827

    David
    Participant

    Yes, I means “shuffle lines randomly”. I know a tool “Sublime Text” has this function.

    #23828

    Mr KT
    Participant

    Hey David,
    I currently shuffle selected text using this macro. Hopefully does what you need or can be adapted fairly easily.

    if (document.CellMode == true ) {
    document.CellMode = false;
    }

    if( document.selection.IsEmpty ){
    // nothing is selected
    alert( “Select the text you want to shuffle\r\nIf this is a delimited file, select all text” );
    }
    else {
    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;
    }

    #23833

    David
    Participant

    Hello,Mr KT! Your macro works very well on my computer. Thank you!

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

You must be logged in to reply to this topic.