English main discussion
Offline
Posts: 282 Joined: Thu Sep 10, 2015 9:53 am
Location: Deutschland
Post
by sexy96 » Tue Oct 24, 2017 8:19 am
I have sorted the words
a
A
b
B
c
C
How to sort them in this way?
a
b
c
A
B
C
or
A
B
C
a
b
c
Notepad ++ is an option
Offline
Posts: 874 Joined: Sat Jan 16, 2010 2:03 pm
Post
by opk44 » Tue Oct 24, 2017 12:38 pm
sexy96 wrote: ...
or
A
B
C
a
b
c
See docs (Format-Eng.txt)
Code: Select all
*****************************************************************
*** Format AkelPad plugin v3.3 ***
*****************************************************************
...
Call("Format::LineSortStrAsc", FLAGS)
Parameters:
FLAGS (sum of the following members):
1 Match case.
2 Match locale (slower).
By default: 0.
...
So, you can use in Context Menu:
"Sorts lines by string ascending + Match case" Call("Format::LineSortStrAsc", 1 ) Icon("%a\AkelFiles\Plugs\Format.dll", 1)
Or you can use
"SortLines.js"
Options:
[*]Key 2-Line content [_] Ignore Case
[*]Entire Line (*) String
Offline
Posts: 282 Joined: Thu Sep 10, 2015 9:53 am
Location: Deutschland
Post
by sexy96 » Wed Oct 25, 2017 6:02 am
The problem is that in the dictionary I have words starting with ć, Ć, ś, Ś - e.t.c
a
A
C
ć
d
Ś
w
Z
How to get this effect?
a <- lower case
ć
d
w
A <- big case
C
Ś
Z
Offline
Posts: 874 Joined: Sat Jan 16, 2010 2:03 pm
Post
by opk44 » Wed Oct 25, 2017 2:49 pm
sexy96
I don't have Polish locale, so I can't reproduce it. But IF YOU HAVE , than try to use FLAG = 3 (Match case + Match locale) instead "1"
Offline
Posts: 282 Joined: Thu Sep 10, 2015 9:53 am
Location: Deutschland
Post
by sexy96 » Wed Oct 25, 2017 3:00 pm
it does not work
"Sorts lines by string ascending + Match case" Call("Format::LineSortStrAsc", 3) Icon("%a\AkelFiles\Plugs\Format.dll", 1)
a
A
C
ć
Ć
Ś
w
Z
Offline
Posts: 1949 Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland
Post
by KDJ » Wed Oct 25, 2017 7:23 pm
sexy96
Try this script:
SortLines_azAZ.js SortLines_azAZ.js
Code: Select all
var bAscending = true;
var oSys = AkelPad.SystemFunction();
var aLine = AkelPad.GetTextRange(0, -1).split("\r").sort(StrCompare);
AkelPad.SetSel(0, -1);
AkelPad.ReplaceSel(aLine.join("\r\n"));
function StrCompare(s1, s2)
{
var bUpper1 = (s1.charAt(0) == s1.charAt(0).toUpperCase());
var bUpper2 = (s2.charAt(0) == s2.charAt(0).toUpperCase());
if (bAscending)
{
if (bUpper1 == bUpper2)
return oSys.Call("Kernel32::lstrcmpiW", s1, s2);
else if (bUpper1 && (! bUpper2))
return 1;
else
return -1;
}
else
{
if (bUpper1 == bUpper2)
return oSys.Call("Kernel32::lstrcmpiW", s2, s1);
else if (bUpper1 && (! bUpper2))
return -1;
else
return 1;
}
}
Offline
Posts: 282 Joined: Thu Sep 10, 2015 9:53 am
Location: Deutschland
Post
by sexy96 » Thu Oct 26, 2017 5:36 am
Dzięki, działa super.
Można to trochę zmodyfikować?
Problem w tym, że to zawsze sortuje cały tekst a nie zaznaczony.
Jak zaznaczę część to przed sortowaniem,
następuje zmiana zaznaczenia na cały tekst.
Offline
Posts: 1949 Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland
Post
by KDJ » Thu Oct 26, 2017 4:57 pm
sexy96
Maybe in this way:
SortLines_azAZ.js SortLines_azAZ.js
Code: Select all
var bAscending = true;
var oSys = AkelPad.SystemFunction();
if (AkelPad.GetSelStart() == AkelPad.GetSelEnd())
AkelPad.SetSel(0, -1);
AkelPad.ReplaceSel(AkelPad.GetSelText().split("\r").sort(StrCompare).join("\r\n"));
function StrCompare(s1, s2)
{
var bUpper1 = (s1.charAt(0) == s1.charAt(0).toUpperCase());
var bUpper2 = (s2.charAt(0) == s2.charAt(0).toUpperCase());
if (bAscending)
{
if (bUpper1 == bUpper2)
return oSys.Call("Kernel32::lstrcmpiW", s1, s2);
else if (bUpper1 && (! bUpper2))
return 1;
else
return -1;
}
else
{
if (bUpper1 == bUpper2)
return oSys.Call("Kernel32::lstrcmpiW", s2, s1);
else if (bUpper1 && (! bUpper2))
return -1;
else
return 1;
}
}
Offline
Posts: 282 Joined: Thu Sep 10, 2015 9:53 am
Location: Deutschland
Post
by sexy96 » Thu Oct 26, 2017 6:19 pm
Thank you very much, it works great