<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Порядок чисел]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=14744&amp;type=atom" />
	<updated>2019-04-29T20:14:08Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=14744</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Порядок чисел]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133931#p133931" />
			<content type="html"><![CDATA[<p>Надеюсь это так <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />.</p>]]></content>
			<author>
				<name><![CDATA[belyankin12]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34408</uri>
			</author>
			<updated>2019-04-29T20:14:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133931#p133931</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Порядок чисел]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133929#p133929" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>wladkokopops пишет:</cite><blockquote><p>Каким способом это можно провернуть используя меньше строк кода?</p></blockquote></div><p>Видимо товарищ опытен, и ему интересно не решение задачи как таковой. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-04-29T19:36:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133929#p133929</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Порядок чисел]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133928#p133928" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>
str = 
(
id1 23
id2 33
id3 11
до последнего пробела например 64
id5 4 
)

Sort, str, F Func

MsgBox % str

Func(a1, a2) {   
    return RegExReplace(a2, &quot;.* &quot;) - RegExReplace(a1, &quot;.* &quot;)
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-04-29T19:32:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133928#p133928</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Порядок чисел]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133927#p133927" />
			<content type="html"><![CDATA[<p>Я уверен, что более опытные товарищи подскажут методы попроще и понадежнее, да и я вполне мог бы что-то получше придумать, если бы зашел в справку, но этот путь пришел мне в голову сразу же, потому покажу его вам:<br /></p><div class="codebox"><pre><code>tarr := [[], [], []]

Loop {
	FileReadLine, line, 1.txt, %A_Index%
	if ErrorLevel
		break
	
	tarr[3][A_Index] := line
	c_Index := A_Index
	
	RegExMatch(line, &quot;id([0-9]+) ([0-9]+)&quot;, end_str)
	
	if (tarr[1].length() = 0) {
		tarr[1][1] := c_Index
		tarr[2][1] := end_str2
		continue
	}
	
	Loop % tarr[2].length()
	{
		if (tarr[2][tarr[2].length()] &lt; end_str2) {
			tarr[2][tarr[2].length() + 1] := end_str2
			tarr[1][tarr[2].length() + 1] := c_Index
			break
		}
		
		if (tarr[2][tarr[2].length() - A_Index + 1] &gt; end_str2) and (tarr[2][tarr[2].length() - A_Index] &lt; end_str2) {
			tarr[2][tarr[2].length() - A_Index + 2] := tarr[2][tarr[2].length() - A_Index + 1]
			tarr[2][tarr[2].length() - A_Index + 1] := end_str2
			
			tarr[1][tarr[2].length() - A_Index + 2] := tarr[1][tarr[2].length() - A_Index + 1]
			tarr[1][tarr[2].length() - A_Index + 1] := c_Index
			break
		}
	}
}

For k, v in tarr[1]
{
	val := tarr[3][v]
	FileAppend, %val%`n, 2.txt
}</code></pre></div><p>На самом деле в процессе обучения фраза &quot;меньше строк кода&quot; не самый лучший подход. Дело в том, что когда вы учитесь чему-то, лучше делать все по-своему, пусть это и костыли, пусть вы используете 200 строк вместо 20. Я почти уверен, что в процессе обучения у вас не стоит задача написать что-то с максимальным быстродействием и минимальным потреблением памяти (это и есть цель минимизации кода). Ограничивая себя вы лишь лишаете себя возможности узнать как работают те или иные команды, которые в &quot;эталонном&quot; решении может быть и не нужны сейчас, но обязательно понадобятся в будущем. Не спорю, что необходимо перенимать более надежные и продвинутые методы у более опытных товарищей, но это не панацея. Пока функциональность вашего скрипта не зависит от выбранного вами метода напрямую (кроме вышеупомянутой скорости и количества потребляемой памяти - что на практике очень редко дает какое-то существенное преимущество) лучше заимствовать лишь алгоритмы (пути достижения цели), а достигать их нужно самому.</p>]]></content>
			<author>
				<name><![CDATA[belyankin12]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34408</uri>
			</author>
			<updated>2019-04-29T19:10:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133927#p133927</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Порядок чисел]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133925#p133925" />
			<content type="html"><![CDATA[<p>Ну если <span class="bbu">прямо такой пример</span>, то я угадаю мелодию с одной ноты.<br /></p><div class="codebox"><pre><code>
str = 
(
id1 23
id2 33
id3 11
id4 64
id5 4 
)

Sort, str, N P5 R

MsgBox % str
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-04-29T18:55:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133925#p133925</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Порядок чисел]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=133921#p133921" />
			<content type="html"><![CDATA[<p>Я честно искал, и ничего не нашел.</p><p>Есть 5 строк в файле<br /></p><div class="codebox"><pre><code>
id1 23
id2 33
id3 11
id4 64
id5 4
</code></pre></div><p>Надо посмотреть что идёт после пробела, сами цифры и составить в порядке убывания (от большего к меньшему),но составить их построчно, то есть в итоге получить:</p><div class="codebox"><pre><code>
id4 64
id2 33
id1 23
id3 11
id5 4
</code></pre></div><p>Каким способом это можно провернуть используя меньше строк кода?</p>]]></content>
			<author>
				<name><![CDATA[wladkokopops]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34240</uri>
			</author>
			<updated>2019-04-29T17:58:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=133921#p133921</id>
		</entry>
</feed>
