<?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: Sorting a 2-Dimensional Array in Java</title>
	<atom:link href="http://publicmind.in/blog/sorting-2d-array-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://publicmind.in/blog/sorting-2d-array-java/</link>
	<description>Simple and Sophisticated</description>
	<lastBuildDate>Tue, 07 Feb 2012 08:29:32 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Kole Black</title>
		<link>http://publicmind.in/blog/sorting-2d-array-java/#comment-2786</link>
		<dc:creator>Kole Black</dc:creator>
		<pubDate>Wed, 25 Jan 2012 05:36:50 +0000</pubDate>
		<guid isPermaLink="false">http://publicmind.in/blog/?p=199#comment-2786</guid>
		<description>Great article post.Much thanks again. Really Cool.</description>
		<content:encoded><![CDATA[<p>Great article post.Much thanks again. Really Cool.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nitin</title>
		<link>http://publicmind.in/blog/sorting-2d-array-java/#comment-2699</link>
		<dc:creator>Nitin</dc:creator>
		<pubDate>Wed, 25 May 2011 11:57:27 +0000</pubDate>
		<guid isPermaLink="false">http://publicmind.in/blog/?p=199#comment-2699</guid>
		<description>I don&#039;t think so, it seems to be inspired from the original &lt;a href=&quot;http://publicmind.in/blog/sorting-2d-array-java/#comment-640&quot; rel=&quot;nofollow&quot;&gt;comment from Lars&lt;/a&gt;. Mark, or in fact Lars, will be able to throw some more light.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think so, it seems to be inspired from the original <a href="http://publicmind.in/blog/sorting-2d-array-java/#comment-640" rel="nofollow">comment from Lars</a>. Mark, or in fact Lars, will be able to throw some more light.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas</title>
		<link>http://publicmind.in/blog/sorting-2d-array-java/#comment-2695</link>
		<dc:creator>Thomas</dc:creator>
		<pubDate>Tue, 24 May 2011 01:17:55 +0000</pubDate>
		<guid isPermaLink="false">http://publicmind.in/blog/?p=199#comment-2695</guid>
		<description>So why is it that [cc lang=&quot;java&quot;]Collections.sort(Arrays.asList(data))[/cc] is faster than [cc lang=&quot;java&quot;]Arrays.sort(data)[/cc] Can that really be?</description>
		<content:encoded><![CDATA[<p>So why is it that</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acollections+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Collections</span></a>.<span style="color: #006633;">sort</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Arrays</span></a>.<span style="color: #006633;">asList</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></div></div>
<p>is faster than</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Arrays</span></a>.<span style="color: #006633;">sort</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span></div></div>
<p>Can that really be?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nitin</title>
		<link>http://publicmind.in/blog/sorting-2d-array-java/#comment-2677</link>
		<dc:creator>Nitin</dc:creator>
		<pubDate>Thu, 12 May 2011 20:39:41 +0000</pubDate>
		<guid isPermaLink="false">http://publicmind.in/blog/?p=199#comment-2677</guid>
		<description>Cool, I appreciate you for sharing your work with the readers here. :). Added a link to it in the post for easy access.</description>
		<content:encoded><![CDATA[<p>Cool, I appreciate you for sharing your work with the readers here. <img src='http://publicmind.in/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Added a link to it in the post for easy access.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://publicmind.in/blog/sorting-2d-array-java/#comment-2676</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Thu, 12 May 2011 20:06:55 +0000</pubDate>
		<guid isPermaLink="false">http://publicmind.in/blog/?p=199#comment-2676</guid>
		<description>Quite often in multidimensional arrays, you may want to do a secondary sort on another column.  For example, sort first on last name, then on first name if the last names are the same.

Here are a couple extensions to Lars Feb 23, 2010 posting.  I apologize in advance that some of the html might get eaten by the browser.

The following code first is a copy of Lars&#039; posting, followed by code for sorting on two columns, then a third example on sorting by an arbitrary number of columns, using an array of column numbers as the input.

&lt;code lang=&quot;java&quot;&gt;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class TwoDcolumnComparator {
    public static &lt; T extends Comparable&gt; void sort(final T [][] toSort,final int onColumn) {
        List list = Arrays.asList(toSort);
        Collections.sort(
            list, new Comparator(){
                public int compare(T[] a, T[] b) {
                    return a[onColumn].compareTo(b[onColumn]);
                }
            }
        );
    }
    public static &lt; T extends Comparable&gt; void sort(final T [][] toSort,final int onColumn1, final int onColumn2) {
        List list = Arrays.asList(toSort);
        Collections.sort(
            list, new Comparator(){
                public int compare(T[] a, T[] b) {
                    if (a[onColumn1].compareTo(b[onColumn1]) == 0) {
                        return a[onColumn2].compareTo(b[onColumn2]);
                    } else {
                        return a[onColumn1].compareTo(b[onColumn1]);
                    }
                }
            }
        );
    }
    public static &lt; T extends Comparable&gt; void sort(final T [][] toSort,final int []onColumn) {
        List list = Arrays.asList(toSort);
        Collections.sort(
            list, new Comparator(){
                public int compare(T[] a, T[] b) {
                    for (int i = 0;i &lt; onColumn.length-1;i++){
                        if (a[onColumn[i]].compareTo(b[onColumn[i]]) != 0) {
                            return a[onColumn[i]].compareTo(b[onColumn[i]]);
                        }
                    }
                    return a[onColumn.length].compareTo(b[onColumn.length]);
                }
            }
        );
    }
}
&lt;/code&gt;&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Quite often in multidimensional arrays, you may want to do a secondary sort on another column.  For example, sort first on last name, then on first name if the last names are the same.</p>
<p>Here are a couple extensions to Lars Feb 23, 2010 posting.  I apologize in advance that some of the html might get eaten by the browser.</p>
<p>The following code first is a copy of Lars&#8217; posting, followed by code for sorting on two columns, then a third example on sorting by an arbitrary number of columns, using an array of column numbers as the input.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Arrays</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collections</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Comparator</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TwoDcolumnComparator <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #339933;">&lt;</span> T <span style="color: #000000; font-weight: bold;">extends</span> Comparable<span style="color: #339933;">&gt;</span> <span style="color: #000066; font-weight: bold;">void</span> sort<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> T <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> toSort,<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> onColumn<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Alist+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">List</span></a> list <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Arrays</span></a>.<span style="color: #006633;">asList</span><span style="color: #009900;">&#40;</span>toSort<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acollections+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Collections</span></a>.<span style="color: #006633;">sort</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; list, <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acomparator+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Comparator</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> compare<span style="color: #009900;">&#40;</span>T<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> a, T<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> a<span style="color: #009900;">&#91;</span>onColumn<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#91;</span>onColumn<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #339933;">&lt;</span> T <span style="color: #000000; font-weight: bold;">extends</span> Comparable<span style="color: #339933;">&gt;</span> <span style="color: #000066; font-weight: bold;">void</span> sort<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> T <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> toSort,<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> onColumn1, <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> onColumn2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Alist+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">List</span></a> list <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Arrays</span></a>.<span style="color: #006633;">asList</span><span style="color: #009900;">&#40;</span>toSort<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acollections+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Collections</span></a>.<span style="color: #006633;">sort</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; list, <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acomparator+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Comparator</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> compare<span style="color: #009900;">&#40;</span>T<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> a, T<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#91;</span>onColumn1<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#91;</span>onColumn1<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> a<span style="color: #009900;">&#91;</span>onColumn2<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#91;</span>onColumn2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> a<span style="color: #009900;">&#91;</span>onColumn1<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#91;</span>onColumn1<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #339933;">&lt;</span> T <span style="color: #000000; font-weight: bold;">extends</span> Comparable<span style="color: #339933;">&gt;</span> <span style="color: #000066; font-weight: bold;">void</span> sort<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> T <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> toSort,<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span>onColumn<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Alist+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">List</span></a> list <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Arrays</span></a>.<span style="color: #006633;">asList</span><span style="color: #009900;">&#40;</span>toSort<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acollections+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Collections</span></a>.<span style="color: #006633;">sort</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; list, <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acomparator+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Comparator</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> compare<span style="color: #009900;">&#40;</span>T<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> a, T<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i <span style="color: #339933;">&lt;</span> onColumn.<span style="color: #006633;">length</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#91;</span>onColumn<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#91;</span>onColumn<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> a<span style="color: #009900;">&#91;</span>onColumn<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#91;</span>onColumn<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> a<span style="color: #009900;">&#91;</span>onColumn.<span style="color: #006633;">length</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#91;</span>onColumn.<span style="color: #006633;">length</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: amit</title>
		<link>http://publicmind.in/blog/sorting-2d-array-java/#comment-1657</link>
		<dc:creator>amit</dc:creator>
		<pubDate>Wed, 08 Dec 2010 08:29:16 +0000</pubDate>
		<guid isPermaLink="false">http://publicmind.in/blog/?p=199#comment-1657</guid>
		<description>Really helpful article</description>
		<content:encoded><![CDATA[<p>Really helpful article</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Line</title>
		<link>http://publicmind.in/blog/sorting-2d-array-java/#comment-1082</link>
		<dc:creator>Line</dc:creator>
		<pubDate>Sun, 22 Aug 2010 05:19:18 +0000</pubDate>
		<guid isPermaLink="false">http://publicmind.in/blog/?p=199#comment-1082</guid>
		<description>The solution is really helpful and I cannot imagine that I can make benefit of 
comparator to deal with array object by itself .. 

Thank you very much  Nitin  .</description>
		<content:encoded><![CDATA[<p>The solution is really helpful and I cannot imagine that I can make benefit of<br />
comparator to deal with array object by itself .. </p>
<p>Thank you very much  Nitin  .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: agil</title>
		<link>http://publicmind.in/blog/sorting-2d-array-java/#comment-1074</link>
		<dc:creator>agil</dc:creator>
		<pubDate>Sun, 13 Jun 2010 17:40:40 +0000</pubDate>
		<guid isPermaLink="false">http://publicmind.in/blog/?p=199#comment-1074</guid>
		<description>Hello Nitin,

Your solution very useful for two Dimensional array with same length.
My question is, can we sort two dimensional array based on some row and based on data length. for example we have an array {{”c”}, {”c”}, {”c”, “d”},{”c”, “a”},{”b”}}. how to get the sorted array like this {{”b”},{”c”},{”c”},{”c”,”a”},{”c”, “d”}}.

Thx a lot Nitin.</description>
		<content:encoded><![CDATA[<p>Hello Nitin,</p>
<p>Your solution very useful for two Dimensional array with same length.<br />
My question is, can we sort two dimensional array based on some row and based on data length. for example we have an array {{”c”}, {”c”}, {”c”, “d”},{”c”, “a”},{”b”}}. how to get the sorted array like this {{”b”},{”c”},{”c”},{”c”,”a”},{”c”, “d”}}.</p>
<p>Thx a lot Nitin.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bizunas</title>
		<link>http://publicmind.in/blog/sorting-2d-array-java/#comment-1047</link>
		<dc:creator>Bizunas</dc:creator>
		<pubDate>Sat, 29 May 2010 14:20:59 +0000</pubDate>
		<guid isPermaLink="false">http://publicmind.in/blog/?p=199#comment-1047</guid>
		<description>Thanks, it helped me alot. No changes needed at all :)</description>
		<content:encoded><![CDATA[<p>Thanks, it helped me alot. No changes needed at all <img src='http://publicmind.in/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: autofei</title>
		<link>http://publicmind.in/blog/sorting-2d-array-java/#comment-1040</link>
		<dc:creator>autofei</dc:creator>
		<pubDate>Fri, 28 May 2010 16:24:01 +0000</pubDate>
		<guid isPermaLink="false">http://publicmind.in/blog/?p=199#comment-1040</guid>
		<description>I just post a working version modified from Lars version. Hope it helpful.</description>
		<content:encoded><![CDATA[<p>I just post a working version modified from Lars version. Hope it helpful.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

