<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Groovy reverse map sort done easy</title>
	<atom:link href="http://www.kellyrob99.com/blog/2009/10/24/groovy-reverse-map-sort-done-easy/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kellyrob99.com/blog/2009/10/24/groovy-reverse-map-sort-done-easy/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=groovy-reverse-map-sort-done-easy</link>
	<description>Tales of development, life and the folly that goes along with both</description>
	<lastBuildDate>Thu, 26 Aug 2010 15:21:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
	<item>
		<title>By: TheKaptain</title>
		<link>http://www.kellyrob99.com/blog/2009/10/24/groovy-reverse-map-sort-done-easy/comment-page-1/#comment-292</link>
		<dc:creator>TheKaptain</dc:creator>
		<pubDate>Thu, 14 Jan 2010 05:37:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=829#comment-292</guid>
		<description>Yeah, wordpress can sometimes be too &#039;helpful&#039; that way. And you&#039;re absolutely right - shame on me for assuming that order was part of the comparison; the assertion I&#039;ve shown is only relevant as far as the items in the map, not their order. I think you&#039;ll find this, however, does properly check that condition.

     def map = [a:3, b:2, c:1]
     map = map.sort {it.value}
     assert (map.keySet() as List) == [&#039;c&#039;,&#039;b&#039;,&#039;a&#039;]
</description>
		<content:encoded><![CDATA[<p>Yeah, wordpress can sometimes be too &#8216;helpful&#8217; that way. And you&#8217;re absolutely right &#8211; shame on me for assuming that order was part of the comparison; the assertion I&#8217;ve shown is only relevant as far as the items in the map, not their order. I think you&#8217;ll find this, however, does properly check that condition.</p>
<p>     def map = [a:3, b:2, c:1]<br />
     map = map.sort {it.value}<br />
     assert (map.keySet() as List) == ['c','b','a']</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keegan</title>
		<link>http://www.kellyrob99.com/blog/2009/10/24/groovy-reverse-map-sort-done-easy/comment-page-1/#comment-291</link>
		<dc:creator>Keegan</dc:creator>
		<pubDate>Thu, 14 Jan 2010 02:14:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=829#comment-291</guid>
		<description>Sorry, looks like wordpress cut my example off, what I had in square brackets was a:3, c:1, b:2</description>
		<content:encoded><![CDATA[<p>Sorry, looks like wordpress cut my example off, what I had in square brackets was a:3, c:1, b:2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keegan</title>
		<link>http://www.kellyrob99.com/blog/2009/10/24/groovy-reverse-map-sort-done-easy/comment-page-1/#comment-290</link>
		<dc:creator>Keegan</dc:creator>
		<pubDate>Wed, 13 Jan 2010 21:43:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=829#comment-290</guid>
		<description>Oops, I must have forgot to do the reassignment. Sorry about that. My statement about the asserts is still true, as someone pointed out to me today (I made the same mistake). For example, put this at the end

assert map == [c 1=&quot;a:1,&quot; 2=&quot;b:2&quot; language=&quot;:3,&quot;][/c]

and you&#039;ll see it too passes. Your assert is good for demonstrating, just something to keep in mind.</description>
		<content:encoded><![CDATA[<p>Oops, I must have forgot to do the reassignment. Sorry about that. My statement about the asserts is still true, as someone pointed out to me today (I made the same mistake). For example, put this at the end</p>
<p>assert map == [/c]</p>
<p>and you&#8217;ll see it too passes. Your assert is good for demonstrating, just something to keep in mind.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TheKaptain</title>
		<link>http://www.kellyrob99.com/blog/2009/10/24/groovy-reverse-map-sort-done-easy/comment-page-1/#comment-289</link>
		<dc:creator>TheKaptain</dc:creator>
		<pubDate>Wed, 13 Jan 2010 17:02:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=829#comment-289</guid>
		<description>Not sure exactly what you mean here Keegan...
The sort method returns a new Map instead of sorting the existing map - perhaps that&#039;s what you&#039;re seeing if you&#039;re still examining the original Map?
Adding some println&#039;s to the code above I see these results:
     Sorting by key before sort - a:3, b:2, c:1
     Sorting by key after sort - c:1,b:2,a:3
     Sorting by value before sort - a:1, b:2, c:3
     Sorting by value after sort - c:3,b:2,a:1</description>
		<content:encoded><![CDATA[<p>Not sure exactly what you mean here Keegan&#8230;<br />
The sort method returns a new Map instead of sorting the existing map &#8211; perhaps that&#8217;s what you&#8217;re seeing if you&#8217;re still examining the original Map?<br />
Adding some println&#8217;s to the code above I see these results:<br />
     Sorting by key before sort &#8211; a:3, b:2, c:1<br />
     Sorting by key after sort &#8211; c:1,b:2,a:3<br />
     Sorting by value before sort &#8211; a:1, b:2, c:3<br />
     Sorting by value after sort &#8211; c:3,b:2,a:1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keegan</title>
		<link>http://www.kellyrob99.com/blog/2009/10/24/groovy-reverse-map-sort-done-easy/comment-page-1/#comment-288</link>
		<dc:creator>Keegan</dc:creator>
		<pubDate>Wed, 13 Jan 2010 16:27:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=829#comment-288</guid>
		<description>Your assertion passes, but it doesn&#039;t compare order. I tried this in Groovy 1.6.7 and 1.7.0 and the order was unchanged from the original. (Compared println of the map to the original). Am I missing something?</description>
		<content:encoded><![CDATA[<p>Your assertion passes, but it doesn&#8217;t compare order. I tried this in Groovy 1.6.7 and 1.7.0 and the order was unchanged from the original. (Compared println of the map to the original). Am I missing something?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
