diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml
index 957e1bba8..27d58e51b 100644
--- a/PowerEditor/installer/nativeLang/english.xml
+++ b/PowerEditor/installer/nativeLang/english.xml
@@ -120,6 +120,7 @@
+
diff --git a/PowerEditor/src/MISC/Common/Sorters.h b/PowerEditor/src/MISC/Common/Sorters.h
index b35e63421..df198c149 100644
--- a/PowerEditor/src/MISC/Common/Sorters.h
+++ b/PowerEditor/src/MISC/Common/Sorters.h
@@ -31,6 +31,7 @@
#include
#include
+#include
// Base interface for line sorting.
class ISorter
@@ -385,4 +386,19 @@ protected:
}
};
+class RandomSorter : public ISorter
+{
+public:
+ unsigned seed;
+ RandomSorter(bool isDescending, size_t fromColumn, size_t toColumn) : ISorter(isDescending, fromColumn, toColumn)
+ {
+ seed = static_cast(time(NULL));
+ }
+ std::vector sort(std::vector lines) override
+ {
+ std::shuffle(lines.begin(), lines.end(), std::default_random_engine(seed));
+ return lines;
+ }
+};
+
#endif //NPP_SORTERS_H
diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc
index 42a13ee65..495acc207 100644
--- a/PowerEditor/src/Notepad_plus.rc
+++ b/PowerEditor/src/Notepad_plus.rc
@@ -322,6 +322,8 @@ BEGIN
MENUITEM "Sort Lines As Integers Descending", IDM_EDIT_SORTLINES_INTEGER_DESCENDING
MENUITEM "Sort Lines As Decimals (Comma) Descending", IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING
MENUITEM "Sort Lines As Decimals (Dot) Descending", IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING
+ MENUITEM SEPARATOR
+ MENUITEM "Sort Lines Randomly", IDM_EDIT_SORTLINES_RANDOMLY
END
POPUP "Comment/Uncomment"
BEGIN
diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp
index cc6875a26..bddf49bf7 100644
--- a/PowerEditor/src/NppCommands.cpp
+++ b/PowerEditor/src/NppCommands.cpp
@@ -550,6 +550,7 @@ void Notepad_plus::command(int id)
case IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING:
case IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING:
case IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING:
+ case IDM_EDIT_SORTLINES_RANDOMLY:
{
std::lock_guard lock(command_mutex);
@@ -619,10 +620,14 @@ void Notepad_plus::command(int id)
{
pSorter = std::unique_ptr(new DecimalCommaSorter(isDescending, fromColumn, toColumn));
}
- else
+ else if (id == IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING || id == IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING)
{
pSorter = std::unique_ptr(new DecimalDotSorter(isDescending, fromColumn, toColumn));
}
+ else
+ {
+ pSorter = std::unique_ptr(new RandomSorter(isDescending, fromColumn, toColumn));
+ }
try
{
_pEditView->sortLines(fromLine, toLine, pSorter.get());
@@ -3449,6 +3454,7 @@ void Notepad_plus::command(int id)
case IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING:
case IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING:
case IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING:
+ case IDM_EDIT_SORTLINES_RANDOMLY:
case IDM_EDIT_BLANKLINEABOVECURRENT:
case IDM_EDIT_BLANKLINEBELOWCURRENT:
case IDM_VIEW_FULLSCREENTOGGLE :
diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp
index dc48201c6..563c188dd 100644
--- a/PowerEditor/src/Parameters.cpp
+++ b/PowerEditor/src/Parameters.cpp
@@ -144,6 +144,7 @@ static const WinMenuKeyDefinition winKeyDefs[] =
{ VK_NULL, IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING, false, false, false, nullptr },
{ VK_NULL, IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING, false, false, false, nullptr },
{ VK_NULL, IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING, false, false, false, nullptr },
+ { VK_NULL, IDM_EDIT_SORTLINES_RANDOMLY, false, false, false, nullptr },
{ VK_Q, IDM_EDIT_BLOCK_COMMENT, true, false, false, nullptr },
{ VK_K, IDM_EDIT_BLOCK_COMMENT_SET, true, false, false, nullptr },
{ VK_K, IDM_EDIT_BLOCK_UNCOMMENT, true, false, true, nullptr },
diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h
index 47ecfefd7..eb827a30c 100644
--- a/PowerEditor/src/menuCmdID.h
+++ b/PowerEditor/src/menuCmdID.h
@@ -130,6 +130,7 @@
#define IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING (IDM_EDIT + 64)
#define IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING (IDM_EDIT + 65)
#define IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING (IDM_EDIT + 66)
+ #define IDM_EDIT_SORTLINES_RANDOMLY (IDM_EDIT + 78)
#define IDM_EDIT_OPENASFILE (IDM_EDIT + 73)
#define IDM_EDIT_OPENINFOLDER (IDM_EDIT + 74)