sort paragraph

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Nick Riviera
Posts: 38
Joined: 25 Aug 2021, 02:47

sort paragraph

11 Apr 2023, 02:33

hi everyone,
how could I change the order of the paragraphs as in the list below.
for example: I copy this paragraphs, then when I paste result is paragraphs with a different order
can be done this whit autohotkey?

thank you very much

copy this:
Paragraph 1
Paragraph 2
Paragraph 3
Paragraph 4
Paragraph 5
Paragraph 6


paste:
Paragraph 4
Paragraph 3
Paragraph 5
Paragraph 2
Paragraph 1
Paragraph 6
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: sort paragraph

11 Apr 2023, 03:08

to me these look like lines, not paragraphs, so i guess step 1 is for u to define what a paragraph is and what delimits one
anyway, here is some sample code

Code: Select all

#Requires AutoHotkey v2.0.2

input := '
(
	Paragraph 1
	Paragraph 1

	Paragraph 2
	Paragraph 2

	Paragraph 3
	Paragraph 3

	Paragraph 4
	Paragraph 4

	Paragraph 5
	Paragraph 5

	Paragraph 6
	Paragraph 6
)'

P := StrSplit(input, '`n`n', '`r')
output := P[4] '`n`n' P[3] '`n`n'  P[5] '`n`n'  P[2] '`n`n'  P[1] '`n`n'  P[6]

MsgBox output

; oldClip := ClipboardAll()
; A_Clipboard := ''
; A_Clipboard := output
; ClipWait()
; Send('^v')
; Sleep(100)
; A_Clipboard := oldClip
Nick Riviera
Posts: 38
Joined: 25 Aug 2021, 02:47

Re: sort paragraph

11 Apr 2023, 04:06

Thank you for your answer

yes, each line contains a paragraph..
unfortunately, I have an older autohotkey version

this is what i want to happen
copyPaste.gif
copyPaste.gif (81.71 KiB) Viewed 314 times
swagfag wrote:
11 Apr 2023, 03:08
to me these look like lines, not paragraphs, so i guess step 1 is for u to define what a paragraph is and what delimits one
anyway, here is some sample code
#Requires AutoHotkey v2.0.2
User avatar
boiler
Posts: 17343
Joined: 21 Dec 2014, 02:44

Re: sort paragraph

11 Apr 2023, 05:09

Nick Riviera wrote: unfortunately, I have an older autohotkey version
You posted in “Ask for Help (v2)” in the main section, which is now for AHK v2, as the sub-forum title indicates. That’s why you got a response using v2. This thread has been moved to the v1 section.
User avatar
Chunjee
Posts: 1493
Joined: 18 Apr 2014, 19:05
Contact:

Re: sort paragraph

11 Apr 2023, 09:11

Nick Riviera wrote:
11 Apr 2023, 02:33
for example: I copy this paragraphs, then when I paste result is paragraphs with a different order
can be done this whit autohotkey?
This can be done with ahk. However I am not sure I see the pattern pasted. It seems to be UNsorted.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 100 guests