How to sort lines in text from 0-9 a-z to all random lines using notepad++ and emeditor
How do i sort a large text file lines to be all random.
i'm using Emeditor Notepad++
if there a way with Regular Expressions add it too if possible
Small part of example lines:
0
1
3
4
5
6
7
8
9
10
A
a
B
b
C
c
D
d
E
e
Need result:
E
8
e
5
a
c
9
B
1
0
b
7
3
4
A
d
C
D
10
6
Solution 1:
TL;DR
As of Notepad++ v7.9, Notepad++ has a feature called Randomize Line Order which does the same thing as the answer given below (i.e. it randomizes the order of lines in a given document or selection).
It can be accessed with Edit → Line Operations → Randomize Line Order.
Original Answer
From what I can gather, neither program has a native line randomization function (much less one that uses regex). However, both have the potential ability to support this kind of function via plugins.
I could not find any pre-made solutions for EmEditor unfortunately but there is a Notepad++ plugin called Python Script which supports another external script that can do basic randomization of lines from within Notepad++.
Regarding the "large" file criteria, Notepad++ may have problems with larger files (though opening a file which is ~500MB is certainly possible without issue). If you do encounter any errors, you may need to split the file into smaller chunks.
Python Script Plugin And RandomizeLines.py
First, download and install the Python Script plugin via the Notepad++ Plugin Manager:
Ex. Python Script Plugin Installation In Notepad++ Plugin Manager
Once the plugin is installed, you will need to restart Notepad++. After restarting, the plugin should appear under Plugins → Python Script.
Next, download this Python-based "npp-randomizelines" script from Github (Clone or Download → Download ZIP). Extract the file and select the RandomizeLines.py file:
Ex. RandomizeLines Master - Extracted
Copy RandomizeLines.py to your Notepad++ → Plugins → Python Scripts → Scripts folder. This may be in a different location than shown depending on your Notepad++ installation.
Ex. RandomizeLines - Notepad++ Plugins Folder
Restart Notepad++ and you should now have a Plugins → Python Script → Scripts → RandomizeLines option.
Ex. Running The RandomizeLines Script
With your original input I get the following after running the script:
Ex. Partial Script Results
B
a
c
b
4
A
Notes
-
When run, if no lines are selected, it will randomize all the lines of the currently open file. If individual lines are highlighted, it will only randomize those lines.
-
I haven't played with the Python Script plugin itself, but it's possible that you could extend the script with Python's native regex module. Regarding syntax, the plugin apparently uses a .dll version of Python 2.7.
-
If you want a similar script/plugin for EmEditor, you are probably going to have to code your own using C++. This doesn't seem like a difficult task (at least for anyone even casually familiar with C++ and simple Windows coding) but it is likely more involved than adding regex to the Notepad++ script mentioned above.