<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3341393</guid>
        <pubDate>Tue, 30 Jul 2013 09:59:45 +0000</pubDate>
        <title>Python - сортировка по любому их трех значений</title>
        <link>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3341393</link>
        <description><![CDATA[Мяут-Настоящий: Мде...<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">from collections import OrderedDict</div><div class="code_line">&nbsp;</div><div class="code_line">D = {&#39;192.168.0.1&#39;: {&#39;sent&#39;:501, &#39;count&#39;: 2},</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#39;192.168.0.2&#39;: {&#39;sent&#39;:120, &#39;count&#39;: 5},</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#39;192.168.1.3&#39;: {&#39;sent&#39;:200, &#39;count&#39;: 3}}</div><div class="code_line">&nbsp;&nbsp; &nbsp; </div><div class="code_line">def print_dict(d):</div><div class="code_line">&nbsp;&nbsp; &nbsp;for ip, data in d.items():</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;print ip, data</div><div class="code_line">&nbsp;</div><div class="code_line">def sort_dict(d, criteria):</div><div class="code_line">&nbsp;&nbsp; &nbsp;return OrderedDict(sorted(((k, v) for k, v in d.items()),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;key=lambda i: i[1][criteria]))</div><div class="code_line">&nbsp;</div><div class="code_line">print &#39;SENT&#39; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">print_dict(sort_dict(D, &#39;sent&#39;))</div><div class="code_line">&nbsp;</div><div class="code_line">print &#39;COUNT&#39;</div><div class="code_line">print_dict(sort_dict(D, &#39;count&#39;))</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>Мяут-Настоящий</author>
        <category>Python</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3341365</guid>
        <pubDate>Tue, 30 Jul 2013 09:12:04 +0000</pubDate>
        <title>Python - сортировка по любому их трех значений</title>
        <link>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3341365</link>
        <description><![CDATA[orb: расскажи подробнее как сделать сортед в моей ситуации]]></description>
        <author>orb</author>
        <category>Python</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3341358</guid>
        <pubDate>Tue, 30 Jul 2013 08:52:47 +0000</pubDate>
        <title>Python - сортировка по любому их трех значений</title>
        <link>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3341358</link>
        <description><![CDATA[Мяут-Настоящий: <strong class='tag-b'>orb</strong>, ты даже про sorted() не знаешь? мде  :)]]></description>
        <author>Мяут-Настоящий</author>
        <category>Python</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3341183</guid>
        <pubDate>Mon, 29 Jul 2013 18:32:31 +0000</pubDate>
        <title>Python - сортировка по любому их трех значений</title>
        <link>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3341183</link>
        <description><![CDATA[orb: пока склонился к sqlite  в памяти]]></description>
        <author>orb</author>
        <category>Python</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3340823</guid>
        <pubDate>Mon, 29 Jul 2013 06:27:43 +0000</pubDate>
        <title>Python - сортировка по любому их трех значений</title>
        <link>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3340823</link>
        <description><![CDATA[orb: Нужно сортировать, например, по самому большому количеству запросов (по count) или самый большой трафик (по значению sent)]]></description>
        <author>orb</author>
        <category>Python</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3340741</guid>
        <pubDate>Sun, 28 Jul 2013 15:40:59 +0000</pubDate>
        <title>Python - сортировка по любому их трех значений</title>
        <link>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3340741</link>
        <description><![CDATA[Мяут-Настоящий: Ну так тебе же упорядоченный словарь и нужен, разве нет?]]></description>
        <author>Мяут-Настоящий</author>
        <category>Python</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3340687</guid>
        <pubDate>Sun, 28 Jul 2013 08:28:45 +0000</pubDate>
        <title>Python - сортировка по любому их трех значений</title>
        <link>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3340687</link>
        <description><![CDATA[orb: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=380273&view=findpost&p=3340681'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Мяут&#045;Настоящий &#064; <time class="tag-quote__quoted-time" datetime="2013-07-28T07:06:47+00:00">28.07.13, 07:06</time></span><div class='quote '>ordereddict</div></div><br>
подробнее, пока ничего не нагуглил полезного<br>
Кроме как появился в 3.1 и делает упорядоченный словарь]]></description>
        <author>orb</author>
        <category>Python</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3340681</guid>
        <pubDate>Sun, 28 Jul 2013 07:06:47 +0000</pubDate>
        <title>Python - сортировка по любому их трех значений</title>
        <link>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3340681</link>
        <description><![CDATA[Мяут-Настоящий: ordereddict?]]></description>
        <author>Мяут-Настоящий</author>
        <category>Python</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3340665</guid>
        <pubDate>Sat, 27 Jul 2013 19:26:30 +0000</pubDate>
        <title>Python - сортировка по любому их трех значений</title>
        <link>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3340665</link>
        <description><![CDATA[orb: нужно что-то типа базы данных, что бы можно было делать выборку]]></description>
        <author>orb</author>
        <category>Python</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3340643</guid>
        <pubDate>Sat, 27 Jul 2013 16:58:58 +0000</pubDate>
        <title>Python - сортировка по любому их трех значений</title>
        <link>https://forum.sources.ru/index.php?showtopic=380273&amp;view=findpost&amp;p=3340643</link>
        <description><![CDATA[orb: Парсим лог и вытягиваем 2 значения:<br>IP и количество переданных байт<br><br>Это все сохраняю в словарь:<br>{&#39;IP&#39; : {&#39;sent&#39;:0, &#39;count&#39;:0}}<br><br>Все выглядит красиво, но по сортировать по количеству обращений или количеству переданных байт нельзя, как сделать правильно?]]></description>
        <author>orb</author>
        <category>Python</category>
      </item>
	
      </channel>
      </rss>
	