Page 1 of 1
Sorting problem.
Posted: Fri Jan 18, 2019 2:19 pm
by sexy96
aa
aa
aa
bb
cc
cc
ee
ee
ee
ee
How do you sort words by number of repetitions?
e.g. from the most common to the single.
ee
ee
ee
ee
aa
aa
aa
cc
cc
bb
Posted: Fri Jan 18, 2019 9:29 pm
by opk44
sexy96
Maybe "offtop", but, probably, the easiest way is to use SQL (
SQLite for example).
Import text into a database. The database query. Export query results to text file.
1. Import file "qq-1.txt" with non-sorted data.
2. Run query:
Code: Select all
select field1, count(field1) as cnt
from 'qq-1'
group by field1
order by cnt desc
3. Save result as "View" with name 'tmpdata'
4. Run query:
Code: Select all
select tmpdata.field1
from 'qq-1', 'tmpdata'
where tmpdata.field1 = 'qq-1'.field1
order by cnt desc
5. Save result as txt file (Export to CSV).
P.S. Import txt file have some bug (the last row in file can ignored) so you must add 1 extra empty line in the end of your file before.
Posted: Sat Jan 19, 2019 3:55 pm
by sexy96
Thanks, too bad you can not do this editor.
Posted: Sat Jan 19, 2019 7:22 pm
by KDJ
sexy96
Use JS script:
Code: Select all
var oSys = AkelPad.SystemFunction();
var sNL = ["\r\n", "\n", "\r"][AkelPad.GetEditNewLine(0) - 1];
var oCount = {};
var aWord;
var n;
if (AkelPad.GetSelStart() == AkelPad.GetSelEnd())
AkelPad.SetSel(0, -1);
aWord = AkelPad.GetSelText().split("\r");
for (n = 0; n < aWord.length; ++n)
{
if (aWord[n] in oCount)
++oCount[aWord[n]];
else
oCount[aWord[n]] = 1;
}
aWord.sort(function CompareValue(sA, sB)
{
if (oCount[sA] == oCount[sB])
return oSys.Call("Kernel32::lstrcmpW", sA, sB);
return (oCount[sB] - oCount[sA]);
}
);
AkelPad.ReplaceSel(aWord.join(sNL));
Posted: Mon Jan 21, 2019 10:45 am
by sexy96
Works great. Thanks so much.
I have a selection of icon sizes (ToolBar): Big or small.
How to set a little smaller than Big?