dict.txt file sorting
- legend maxfreak
- Posts: 73
- Joined: 03 Sep 2017, 04:35
dict.txt file sorting
I have a dict.txt file containing all the English words of length 1>>>>>, so how do i sort my dict.txt file to contain words of length 3> (3 words and above till infinity) only, 4>(4 and above) only, 5>, 6>, 7>, 8> and so many other to my likeness
Re: dict.txt file sorting
Try this, you can use FileRead,dict,dict.txt or Loop,Read, dict.txt to read file contents:
Code: Select all
dict:="
(
two
key
AutoHotkey
length
what
about
me
get
find
search
long
alphabet
)"
max:=0
Loop,Parse,dict,`n,`r
If (StrLen(A_LoopField)>max)
max:=StrLen(A_LoopField)
obj:=[]
Loop % max
obj.Push([])
Loop,Parse,dict,`n,`r
obj[StrLen(A_LoopField)].Push(A_LoopField)
for k,v in obj
for k,v in v
output.=v "`n"
output:=RTrim(output,"`n")
MsgBox % output
Re: dict.txt file sorting
Here's a try:
Code: Select all
q:: ;sort list by length/by length and alphabetically
vText := " ;continuation section
(
two
key
AutoHotkey
length
what
about
me
get
find
search
long
alphabet
)"
;sorted by length then alphabetically
vOutput := ""
VarSetCapacity(vOutput, StrLen(vText)*2*2)
Loop, Parse, vText, `n, `r
vOutput .= Format("{:04}", StrLen(A_LoopField)) A_LoopField "`n"
Sort, vOutput
MsgBox, % "[" vOutput "]"
vOutput := RegExReplace(vOutput, "(^|`n)\K....")
vOutput := StrReplace(vOutput, "`n", "`r`n")
MsgBox, % "[" vOutput "]"
;sorted by length
oArray := {}
Loop, Parse, vText, `n, `r
oArray[StrLen(A_LoopField)] .= A_LoopField "`r`n"
vOutput := ""
for vKey, vValue in oArray
vOutput .= vValue
MsgBox, % "[" vOutput "]"
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: dict.txt file sorting
Amazing the help you guys give to people with no interest in learning anything (and its fairly obvious it is going to be used for s p a m purposes given the other posts by the OP on how to "paste" in whatsapp). If he even googled he would found various solutions already.
- legend maxfreak
- Posts: 73
- Joined: 03 Sep 2017, 04:35
Re: dict.txt file sorting
Its not for s p a m purpose sirGuest wrote:Amazing the help you guys give to people with no interest in learning anything (and its fairly obvious it is going to be used for s p a m purposes given the other posts by the OP on how to "paste" in whatsapp). If he even googled he would found various solutions already.
- FanaticGuru
- Posts: 1906
- Joined: 30 Sep 2013, 22:25
Re: dict.txt file sorting
Pretty much a textbook case for a custom sort function.
FG
Code: Select all
vText := " ;continuation section
(
two
key
AutoHotkey
length
what
about
me
get
find
search
long
alphabet
)"
Sort, vText, F Sort_Custom
MsgBox % vText
Sort_Custom(a,b)
{
if (L := StrLen(a) - StrLen(b))
return L
return a > b ? 1 : a < b ? -1 : 0
}
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: dict.txt file sorting
Hi fellow pre-crime investigator!Gast wrote:Amazing the help you guys give to people with no interest in learning anything (and its fairly obvious it is going to be used for s p a m purposes given the other posts by the OP on how to "paste" in whatsapp). If he even googled he would found various solutions already.
Erm, wait ... you are supporting spammers with advising them to search via Google bc you know that there are already various spamming solutions available?!
https://i.imgflip.com/ug71e.jpg
- FanaticGuru
- Posts: 1906
- Joined: 30 Sep 2013, 22:25
Re: dict.txt file sorting
I answer post for about the same reason others might do crossword puzzles.Guest wrote:Amazing the help you guys give to people with no interest in learning anything (and its fairly obvious it is going to be used for s p a m purposes given the other posts by the OP on how to "paste" in whatsapp). If he even googled he would found various solutions already.
It entertains me, exercises my brain, and increases my knowledge.
So I tend to only answer questions that entertain me in some way.
Which means I answer questions in the "Gaming" section less and less even though that is where I started as the questions are very repetitive, simple, incoherent or near impossible.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks