- AuthorPosts
- October 11, 2018 at 6:55 am #23819
David
ParticipantIn 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!
October 11, 2018 at 8:45 am #23820Yutaka Emura
KeymasterI just want to clarify. By “random sort”, do you mean shuffle lines (or cells) randomly? Then we will think about that in the future.
October 11, 2018 at 8:03 pm #23827David
ParticipantYes, I means “shuffle lines randomly”. I know a tool “Sublime Text” has this function.
October 12, 2018 at 5:41 am #23828Mr KT
ParticipantHey 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;
}October 13, 2018 at 6:45 am #23833David
ParticipantHello,Mr KT! Your macro works very well on my computer. Thank you!
- AuthorPosts
- You must be logged in to reply to this topic.