<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AKH: Сортировка массива.]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=14662</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=14662&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AKH: Сортировка массива.».]]></description>
		<lastBuildDate>Thu, 28 Mar 2019 20:56:17 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133219#p133219</link>
			<description><![CDATA[<p>Ну вот, оказывается всё не так уж сложно. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 28 Mar 2019 20:56:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133219#p133219</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133218#p133218</link>
			<description><![CDATA[<p>Что-то типа этого вышло в итоге:<br /></p><div class="codebox"><pre><code>sortArray(array, key := &quot;&quot;, desc := 1, string := 0)
{
	str := &quot;&quot;, d1 := Chr(1), d2 := Chr(2)
	for k, v in array
		str .= (str = &quot;&quot; ? &quot;&quot; : d1) . (key ? v[key] : v) . d2 . k

	Sort, str, % (desc ? &quot;R&quot; : &quot;&quot;) (string ? &quot;&quot; : &quot;N&quot;) &quot;D&quot; . d1
	newArr := []
	Loop, parse, str, % d1
		newArr.Push(array[ RegExReplace(A_LoopField, &quot;.+&quot; . d2) ])
	return newArr
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Phoenixxx_Czar)]]></author>
			<pubDate>Thu, 28 Mar 2019 20:50:21 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133218#p133218</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133217#p133217</link>
			<description><![CDATA[<p>Не думал что он подойдет, то есть просто заменить &quot;v[key]&quot; на &quot;v&quot; и дело в шляпе?</p>]]></description>
			<author><![CDATA[null@example.com (Phoenixxx_Czar)]]></author>
			<pubDate>Thu, 28 Mar 2019 20:42:10 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133217#p133217</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133216#p133216</link>
			<description><![CDATA[<p>Так а в чём трудность прменить тот же принцип для более простого случая?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 28 Mar 2019 17:27:12 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133216#p133216</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133215#p133215</link>
			<description><![CDATA[<p>А что насчет простого массива?<br /></p><div class="codebox"><pre><code>array := [13, 4, 1, 58, 25]</code></pre></div><p>Я находил код, но он слишком громоздкий и изменял основной массив (что-то по типу byRef).<br /></p><div class="codebox"><pre><code>SortArray(Array, Order := &quot;A&quot;)
{
	;Order A: Ascending, D: Descending, R: Reverse
	MaxIndex := ObjMaxIndex(Array)
	If (Order == &quot;R&quot;)
	{
		count := 0
		Loop, % MaxIndex
			ObjInsert(Array, ObjRemove(Array, MaxIndex - count++))
		Return
	}
	Partitions := &quot;|&quot; ObjMinIndex(Array) &quot;,&quot; MaxIndex
	Loop
	{
		comma := InStr(this_partition := SubStr(Partitions, InStr(Partitions, &quot;|&quot;, False, 0)+1), &quot;,&quot;)
		spos := pivot := SubStr(this_partition, 1, comma-1) , epos := SubStr(this_partition, comma+1)
		if (Order == &quot;A&quot;)
		{
			Loop, % epos - spos
			{
				if (Array[pivot] &gt; Array[A_Index+spos])
					ObjInsert(Array, pivot++, ObjRemove(Array, A_Index+spos))
			}
		}
		else
		{
			Loop, % epos - spos
			{
				if (Array[pivot] &lt; Array[A_Index+spos])
					ObjInsert(Array, pivot++, ObjRemove(Array, A_Index+spos))
			}
		}
		Partitions := SubStr(Partitions, 1, InStr(Partitions, &quot;|&quot;, False, 0)-1)
		if (pivot - spos) &gt; 1    ;if more than one elements
			Partitions .= &quot;|&quot; spos &quot;,&quot; pivot-1        ;the left partition
		if (epos - pivot) &gt; 1    ;if more than one elements
			Partitions .= &quot;|&quot; pivot+1 &quot;,&quot; epos        ;the right partition
	}
	Until !Partitions
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Phoenixxx_Czar)]]></author>
			<pubDate>Thu, 28 Mar 2019 14:59:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133215#p133215</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133070#p133070</link>
			<description><![CDATA[<p>Вот так корректнее:<br /></p><div class="codebox"><pre><code>arr := [ {id: 43, isAFK: 1, nick: &quot;Thiago_Montesdeoca&quot;, rankNum:  2}
       , {id: 40, isAFK: 0, nick: &quot;kukumba&quot;           , rankNum: 10}
       , {id:  5, isAFK: 1, nick: &quot;blackboss&quot;         , rankNum:  3} ]
key := &quot;rankNum&quot;

str := &quot;&quot;, d1 := Chr(1), d2 := Chr(2)
for k, v in arr
   str .= (str = &quot;&quot; ? &quot;&quot; : d1) . v[key] . d2 . k

Sort, str, % &quot;D&quot; . d1
newArr := []
Loop, parse, str, % d1
   newArr.Push(arr[ RegExReplace(A_LoopField, &quot;.+&quot; . d2) ])

for k, v in newArr
   MsgBox, % v.nick</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 22 Mar 2019 21:44:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133070#p133070</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133068#p133068</link>
			<description><![CDATA[<p><a href="https://autohotkey.com/docs/Variables.htm#concat">Здесь</a>.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 22 Mar 2019 16:49:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133068#p133068</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133067#p133067</link>
			<description><![CDATA[<p>Где можно прочитать про точку? Не раз замечал ее присутствие, но думал это проделки PHP <img src="//forum.script-coding.com/img/smilies/big_smile.png" width="15" height="15" />.</p>]]></description>
			<author><![CDATA[null@example.com (Phoenixxx_Czar)]]></author>
			<pubDate>Fri, 22 Mar 2019 16:46:29 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133067#p133067</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133066#p133066</link>
			<description><![CDATA[<div class="codebox"><pre><code>Sort, str, % &quot;RD&quot; . d</code></pre></div><p>После точки пробел нужен. Или по-другому:</p><div class="codebox"><pre><code>Sort, str, RD%d%</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 22 Mar 2019 16:45:22 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133066#p133066</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133065#p133065</link>
			<description><![CDATA[<p>Что-то не получается у меня добавить &quot;R&quot;, как и куда правильно ее добавить?<br />Пробовал и с пробелом и без, не дало результатов.<br /></p><div class="codebox"><pre><code>Sort, str, % &quot;D&quot; .d &quot;R&quot;
Sort, str, % &quot;D&quot; .d &quot; R&quot;
Sort, str, % &quot;RD&quot; .d
Sort, str, % &quot;R D&quot; .d</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Phoenixxx_Czar)]]></author>
			<pubDate>Fri, 22 Mar 2019 16:37:37 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133065#p133065</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133064#p133064</link>
			<description><![CDATA[<p>Так смотрите хелп по Sort, там всё есть.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 22 Mar 2019 16:23:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133064#p133064</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133063#p133063</link>
			<description><![CDATA[<p><strong>teadrinker</strong>, а можно как-то обратную сортировку? (DESC)</p>]]></description>
			<author><![CDATA[null@example.com (Phoenixxx_Czar)]]></author>
			<pubDate>Fri, 22 Mar 2019 16:15:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133063#p133063</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133059#p133059</link>
			<description><![CDATA[<div class="quotebox"><cite>Phoenixxx_Czar пишет:</cite><blockquote><p>Можно какой-то пример?</p></blockquote></div><p>Готового примера нет, а писать лень.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Fri, 22 Mar 2019 15:35:58 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133059#p133059</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133058#p133058</link>
			<description><![CDATA[<p>Я так и не понял, зачем нужно было в JSON переводить.<br /></p><div class="codebox"><pre><code>arr := [ {id: 43, isAFK: 1, nick: &quot;Thiago_Montesdeoca&quot;, rankNum:  2}
       , {id: 40, isAFK: 0, nick: &quot;kukumba&quot;           , rankNum: 10}
       , {id:  5, isAFK: 1, nick: &quot;blackboss&quot;         , rankNum:  3} ]
key := &quot;rankNum&quot;

str := &quot;&quot;, d := Chr(1)
for k, v in arr
   str .= (str = &quot;&quot; ? &quot;&quot; : d) . v[key] . &quot;~&quot; . k

Sort, str, % &quot;D&quot; . d
newArr := []
Loop, parse, str, % d
   newArr.Push(arr[ RegExReplace(A_LoopField, &quot;.+~&quot;) ])

for k, v in newArr
   MsgBox, % v.nick</code></pre></div><p>Это строчная сортировка. Для числовой добавьте N к опциям Sort.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 22 Mar 2019 15:35:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133058#p133058</guid>
		</item>
		<item>
			<title><![CDATA[Re: AKH: Сортировка массива.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=133057#p133057</link>
			<description><![CDATA[<p>AHK массива.</p>]]></description>
			<author><![CDATA[null@example.com (Phoenixxx_Czar)]]></author>
			<pubDate>Fri, 22 Mar 2019 15:14:15 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=133057#p133057</guid>
		</item>
	</channel>
</rss>
