<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Kaptain on ... stuff &#187; sort</title>
	<atom:link href="http://www.kellyrob99.com/blog/tag/sort/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kellyrob99.com/blog</link>
	<description>Tales of development, life and the folly that goes along with both</description>
	<lastBuildDate>Sun, 04 Dec 2011 21:51:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Groovy reverse map sort done easy</title>
		<link>http://www.kellyrob99.com/blog/2009/10/24/groovy-reverse-map-sort-done-easy/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=groovy-reverse-map-sort-done-easy</link>
		<comments>http://www.kellyrob99.com/blog/2009/10/24/groovy-reverse-map-sort-done-easy/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 06:54:31 +0000</pubDate>
		<dc:creator>TheKaptain</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[theKaptain]]></category>

		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=829</guid>
		<description><![CDATA[Sorting a Map by value with Groovy is very simple, due to the added &#8216;sort&#8217; method on the Map interface. Turns out doing a reverse sort on a Map by values is almost as easy. Using the spaceship operator (&#8216;< =>&#8216;) you can define a very terse syntax for accessing &#8216;compareTo&#8217;, as long as the [...]
Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/05/10/gracelets-and-seam-a-dsl-for-facelets-with-easy-integration/' rel='bookmark' title='Gracelets and Seam &#8211; a DSL for Facelets and Groovy with easy integration'>Gracelets and Seam &#8211; a DSL for Facelets and Groovy with easy integration</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/10/25/grails-ui-datatable-using-xml-for-a-model/' rel='bookmark' title='Grails-UI DataTable using XML for a model'>Grails-UI DataTable using XML for a model</a></li>
<li><a href='http://www.kellyrob99.com/blog/2010/05/15/achieving-groovy-like-fluency-in-java-with-google-collections/' rel='bookmark' title='Achieving Groovy-like Fluency in Java with Google Collections'>Achieving Groovy-like Fluency in Java with Google Collections</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Sorting a Map by value with Groovy is very simple, due to the added &#8216;sort&#8217; method on the Map interface.</p>
<pre class="brush: groovy; title: ; notranslate">
def map = [a:3, b:2, c:1]
map = map.sort {it.value}
assert map == 1
</pre>
<p>Turns out doing a reverse sort on a Map by values is almost as easy.</p>
<pre class="brush: groovy; title: ; notranslate">
def map = [a:1, b:2, c:3]
map = map.sort {a, b -&gt; b.value &lt;=&gt; a.value}
assert map == 1
</pre>
<p>Using the spaceship operator (&#8216;< =>&#8216;) you can define a very terse syntax for accessing &#8216;compareTo&#8217;, as long as the values in the map implement Comparable that is.<br />
Nice!</p>
<!-- AdSense Now! V1.95 -->
<!-- Post[count: 2] -->
<div class="adsense adsense-leadout" style="float:right;margin: 12px;"><script type="text/javascript"><!--
google_ad_client = "pub-6955914197200080";
/* 728x90, created 8/3/09 */
google_ad_slot = "4051815125";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p>Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/05/10/gracelets-and-seam-a-dsl-for-facelets-with-easy-integration/' rel='bookmark' title='Gracelets and Seam &#8211; a DSL for Facelets and Groovy with easy integration'>Gracelets and Seam &#8211; a DSL for Facelets and Groovy with easy integration</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/10/25/grails-ui-datatable-using-xml-for-a-model/' rel='bookmark' title='Grails-UI DataTable using XML for a model'>Grails-UI DataTable using XML for a model</a></li>
<li><a href='http://www.kellyrob99.com/blog/2010/05/15/achieving-groovy-like-fluency-in-java-with-google-collections/' rel='bookmark' title='Achieving Groovy-like Fluency in Java with Google Collections'>Achieving Groovy-like Fluency in Java with Google Collections</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.kellyrob99.com/blog/2009/10/24/groovy-reverse-map-sort-done-easy/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

