{"id":79,"date":"2006-12-18T13:05:30","date_gmt":"2006-12-18T18:05:30","guid":{"rendered":"http:\/\/stein.everybody.org\/brain\/java-sort-a-set\/"},"modified":"2011-03-10T10:57:30","modified_gmt":"2011-03-10T15:57:30","slug":"java-sort-a-set","status":"publish","type":"post","link":"https:\/\/jeremystein.com\/brain\/java-sort-a-set\/","title":{"rendered":"Java &#8211; Sort a set"},"content":{"rendered":"<p>Here&#8217;s my utility to method to sort a set in Java 5:<\/p>\n<p>@SuppressWarnings(&quot;unchecked&quot;)<br \/>\npublic static &lt;T extends Comparable&gt; List&lt;T&gt; asSortedList(Collection&lt;T&gt; collection) {<br \/>\n&nbsp;&nbsp;T[] array = collection.toArray(<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;(T[])new Comparable[collection.size()]);<br \/>\n&nbsp;&nbsp;Arrays.sort(array);<br \/>\n&nbsp;&nbsp;return Arrays.asList(array);<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s my utility to method to sort a set in Java 5: @SuppressWarnings(&quot;unchecked&quot;) public static &lt;T extends Comparable&gt; List&lt;T&gt; asSortedList(Collection&lt;T&gt; collection) { &nbsp;&nbsp;T[] array = collection.toArray( &nbsp;&nbsp;&nbsp;&nbsp;(T[])new Comparable[collection.size()]); &nbsp;&nbsp;Arrays.sort(array); &nbsp;&nbsp;return Arrays.asList(array); }<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-79","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/79","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/comments?post=79"}],"version-history":[{"count":0,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/79\/revisions"}],"wp:attachment":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/media?parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/categories?post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/tags?post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}